+ 1
How to create char ARRAY ?
Here it's considering as a single string How can I get an array ['a','b','c'] https://code.sololearn.com/cr2eclG8t8Uk/?ref=app
9 Respuestas
+ 6
Levi ,
you may be irritated by the output result when printing the array. there is no string type for array, but you can use 'u' for an array of type unicode charracter. the code:
import array
a=array.array('u', ['a', 'b'])
print(a)
a.append('x')
print(a)
shows:
array('u', 'ab')
array('u', 'abx')
this is how the character array is represented.
you can find here more info about python array module.
https://docs.python.org/3/library/array.html
keep in mind that it is used only very rarely. most codes are using python lists or numpy arrays.
+ 4
Levi array stores only one type of data
list stores any combination of different types of data
you can store a text file along with a integer in list which would not be possible in an array
+ 3
Lothar An additional question regarding arrays,
Why arrays is more compact in memory size when compared to list ?
+ 1
try to print the individual elements of the array
try to print the length of the array
try assigning 'abc' as a single element to the array
+ 1
I think you are looking for list out of string
You may use split method on string
0
to create an array using character data type i.e
char arr[4];
- 1
What is <br> role in html?