0

How to use (join) in python ?

17th Apr 2020, 1:00 PM
Albert
Albert - avatar
3 Réponses
+ 1
You can also try this... >>>a = list('blahblah') #create a list of every letter in the string >>>b = '
#x27;.join(a) #puts "
quot; in between each letter >>>print(b) >>>b$l$a$h$b$l$a$h .join() takes split up data and "glues" it together with whatever you want
17th Apr 2020, 5:15 PM
Slick
Slick - avatar
+ 2
Oh alright. >>>b = 'cool'.split('o') >>>print(b) >>>['c', '', 'l'] >>>a = 'O'.join(b) >>>print(a) >>>cOOl This is just an example, there are more uses. By using split to take the lower case 'o's out it leaves us with a list of letters not including 'o' in "cool". Then i call .join() on the string value of O, and tell that string to join together the letters in list "b". It then "replaces" the 'o's with 'O's.
17th Apr 2020, 5:10 PM
Slick
Slick - avatar
+ 1
If you only have mobile, download pydroid 3 or QPython 3L. If you have a computer, download python! It comes with its own IDE made with python.
17th Apr 2020, 1:32 PM
Slick
Slick - avatar