+ 1

question about python

how can I make a string from a list?

14th Dec 2018, 7:47 AM
최호준
5 ответов
+ 10
What do you mean? Do you mean like this? lst = ["s", "o", "l", "o", "l", "e", "a", "r", "n"] print("".join(x for x in lst)) #prints sololearn lst2 = ["solo", "learn"] print("".join(x for x in lst2)) #prints sololearn
14th Dec 2018, 7:58 AM
Lambda_Driver
Lambda_Driver - avatar
+ 1
Thank you
14th Dec 2018, 8:13 AM
최호준
0
Thank you!
14th Dec 2018, 8:10 AM
최호준
0
There is an useful method for that. "".join.(list) But another way is: string = "" for i in list: string += i
14th Dec 2018, 8:12 AM
Seb TheS
Seb TheS - avatar
0
If you need list of the available list or string methods and functions type dir(list) or dir(str), you may also type help() for Python's large documentation.
14th Dec 2018, 8:23 AM
Seb TheS
Seb TheS - avatar