我有python的问题,我无法弄明白.我想在用户输入单词时打印一个单词的重复,然后他会告诉该单词将重复多少次.顺便说一句,我不能.这里代码到目前为止
b = raw_input 'enter word'
c = input 'enter the amount of time the word will repeat'
for g in range (c)
print (b)
Run Code Online (Sandbox Code Playgroud)
就像你看到你可以看到输入的重复但在垂直线上,我怎么能水平打印?
非常简单.只需添加逗号即可.
print (b),
Run Code Online (Sandbox Code Playgroud)
所以你的代码变成:
b = raw_input('enter word: ')
c = input('enter the amount of time the word will repeat: ')
for g in range (c):
print b,
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
631 次 |
| 最近记录: |