How to add a space when you're multiplying variables in python

前端 未结 2 998
闹比i
闹比i 2021-01-23 13:21

Here is my code

print(\"Type in another set of words\")
    x = input()
    print(\"Now type in how many times you want it to appear (WHOLE NUMBERS ONLY!)\")
           


        
相关标签:
2条回答
  • 2021-01-23 13:33

    Use str.join to place a space between a sequence of strings:

    print(' '.join([x] * c))
    
    0 讨论(0)
  • 2021-01-23 13:53

    You can use string formatting:

    print('{} '.format(x)*c)
    
    0 讨论(0)
提交回复
热议问题