咱们先一块来看看我写的吧:
————————————————
user=input('Please enter user name ')
password=input('Please enter password ')
while user== 'admin' and password== 'python':
print('welcome')
break
else:
('wrong password')
结果是:
Please enter user name admin
Please enter password python
welcome
—————————————————
解读:我们先用input()让用户进行帐号和密码的输入,分别赋值给 user 和 password
接着我们用到while 进行变量的比较,正确则输出 welcome 错误则输出 wrong password