【发布时间】:2026-01-15 07:20:05
【问题描述】:
Python:用户输入数字,然后输入一个字母,然后按照数字表示的次数输出该字母:
例如
"Enter Integer": 4
"Enter Letter": a
输出
a
a
a
a
这是我目前拥有的,但出现名称错误,' ' is not defined, ' ' is the letter
integer = int(input("Enter a positive integer: "))
character = str(input("Enter a character, e.g. 'a': "))
for i in range(integer):
print str(character)
如果我输入 4, 4 它会给我
4
4
4
4
可以,但是不会输出字母,我是 python 新手,请见谅
有什么想法吗?
【问题讨论】:
-
无法重现。我觉得很好
-
EV。 Kounis,我可以发布一个 imgur 链接吗?
标签: python string integer output prompt