+ 1
How to split string into list?
I tried .split command,buts it's not working
4 Respuestas
+ 1
Remember the split function returns a list, so you have to store that returned value into a variable.
var = "this is a string"
alist = var.split()
print(alist)
This will create a list from the string and because we didn't pass in any arguments into the split function it'll split based off of white space.
+ 1
to split the string and place all characters into a list, u can use the list() function:
my_var = "my string"
my_list = list(my_var)
print(my_list)
#output: ['m', 'y', ' ', 's', 't', 'r', 'i', 'n', 'g']
0
a=['a'.......'z']
b=['p','l'i=j=0
while j <2
if a [i]=b [j]
k=0
while k <26
b [j]=a [i+k ]
print (b[j])
k=k+1
i=i+1
j=j+1