+ 1
Join function - String
print("* ".join(["spam", "eggs", "ham"])) Why ham is not changed?
3 Respostas
+ 8
join() only puts the string given between elements. Since ham is the last one, nothing gets put in after it.
+ 3
Because split() splits a string into a list (hence the name) with the string provided as the separator. If you did
print("spam, eggs, ham".split(", "))
you would get
['spam', 'eggs', 'ham']
+ 1
print("spam, eggs, ham".split("* "))
why this code doesn't print
spam* eggs* ham ?