0
How to use (join) in python ?
3 Respuestas
+ 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
+ 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.
+ 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.