这是我的代码
print("Type in another set of words")
x = input()
print("Now type in how many times you want it to appear (WHOLE NUMBERS ONLY!)")
c = int(input())
print(x * c)
我想在每次单词相乘之间添加一个空格。这可能吗?
最佳答案
使用str.join在字符串序列之间放置一个空格:
print(' '.join([x] * c))
关于python - 在python中乘以变量时如何添加空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18938965/