I am starting to learn Python and this is my first day. I have read a book on learning Python and I found a built-in function called split()
. I tried it out and worked, but I noticed that it did not include the separator in the list it made. Is there anyway I could save it? (I don't want to manually add the separator to the list.)
Here is my code:
text = "hello!Hello!"
newtext = text.split("!")
for i in range(len(newtext)):
print(newtext[i])
Output:
hello
Hello