为什么我在pycharm中收到一条NameError消息,我已将此代码放入另一个程序中,它运行正常。
profiles = {
'gabe': '12345',
'greg': '54321'
}
username = input('What is your username: ')
if username in profiles:
password = profiles[username]
if password == str(input('What is your password: ')):
print('You logged in')
else:
print('Incorrect password')
else:
print('Your username is incorrect')
控制台:
What is your username: gabe
Traceback (most recent call last):
File "/Users/gaberbit/PycharmProjects/logon/login.py", line 6, in
<module>
username = input('What is your username: ')
File "<string>", line 1, in <module>
NameError: name 'gabe' is not defined
Process finished with exit code 1