+ 4

Method (Python3)

Someone remenber de method that does this? x = "123" x = x."method"(",") print(x) output=1,2,3 I forgot what is its name but i know that exist...

23rd Aug 2018, 3:16 PM
I Am Arthur
I Am Arthur - avatar
7 Answers
23rd Aug 2018, 9:18 PM
Markus Kaleton
Markus Kaleton - avatar
+ 10
how about this: ",".join('123') syntax is different but working with lists too
23rd Aug 2018, 9:52 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 3
what is this I got error why you put method between " " .
23rd Aug 2018, 4:42 PM
Maninder $ingh
Maninder $ingh - avatar
+ 1
Maninder Singh i dont know the method, it is not part of the code, please read it again
23rd Aug 2018, 8:48 PM
I Am Arthur
I Am Arthur - avatar
+ 1
Mert Yazıcı No, the split method is different
23rd Aug 2018, 8:48 PM
I Am Arthur
I Am Arthur - avatar
+ 1
Markus Kaleton Not this module but it has the same result ,thank you so much
23rd Aug 2018, 9:39 PM
I Am Arthur
I Am Arthur - avatar
+ 1
Like Mert Yazıcı said, you can use x = ','.join(x) to put commas between the numbers in the string. Should work for any kind of iterable (strings, lists, tuples)
23rd Aug 2018, 11:26 PM
Jordan
Jordan - avatar