![](/img/trans.png)
[英]Add space between each character after it is multiplied n times in python
[英]Space between each character in python
我需要一个简单的 python 代码,它可以让您输入文本并在每个字符之间用空格显示它。
我做了这样的东西,它可以工作,但现在我不知道如何用空格制作它
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)
如评论中所述,您正在寻找字符串的连接方法。 它需要一个可迭代对象并使用字符串作为分隔符将其连接在一起。 由于字符串本身是可迭代的,您可以简单地做
' '.join('Hello')
>>> H e l l o
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.