Atom NameError: name '' is not defined
Atom NameError: name '' is not defined
我正在编写一个简单的团队选择器程序,但我不断收到此错误消息:
NameError: name 'y' is not defined
我的代码在在线 python 解释器中工作,所以我不确定是我的代码还是我使用的文本编辑器是 atom。
我的代码截图:
此代码应该有效
players = []
while input('Would you like to add players to your team? Y/N').lower() == 'y':
name = input('What is the players name?')
players.append(name)
print(f'You have {len(players)} players on your team')
您需要调用 lower
(如 lower()
)才能实际获得小写答案,而不是函数 lower
。此外,我将添加播放器输入移至 while 循环以使其更干净。
我正在编写一个简单的团队选择器程序,但我不断收到此错误消息:
NameError: name 'y' is not defined
我的代码在在线 python 解释器中工作,所以我不确定是我的代码还是我使用的文本编辑器是 atom。
我的代码截图:
此代码应该有效
players = []
while input('Would you like to add players to your team? Y/N').lower() == 'y':
name = input('What is the players name?')
players.append(name)
print(f'You have {len(players)} players on your team')
您需要调用 lower
(如 lower()
)才能实际获得小写答案,而不是函数 lower
。此外,我将添加播放器输入移至 while 循环以使其更干净。