I need a simple python code that lets you enter text and shows it with space between each character.
I have made something like this and it works but now I don't know how to make it with spaces
text = input("text: ")
print(f"{text}")
text = input("text: ")
text = ' '.join(list(text))
print(text)
text = input("enter text here")
words=text.split()
output=""
for word in words:
for letter in word:
output = output + letter + " "
print(output)
As mentioned in the comments, you are looking for the join method of a string. It takes an iterable and concatenates it together using the string as separator. As a string is an iterable itself you can simply do
' '.join('Hello')
>>> H e l l o
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.