python day1-作业
readme:
输入用户名和密码,并进行判断:如果输入正确,提示成功登录;如果不正确,提示错误用户名和密码。
coding:
import getpass
_username = 'john'
_passwd = '123'
user = input("please enter your name:")
passwd = input("please enter your password:")
if user == _username and passwd == _passwd:
print("welcome user %s login!"% user)
else:
print("you entered wrong username or password!")
超过3次,提示锁定用户
coding:
import getpass
count = 0
_username = 'john'
_passwd = '123'
while count <3:
user = input("please enter your name:")
passwd = input("please enter your password:")
if user == _username and passwd == _passwd:
print("welcome user %s login!"% user)
else:
print("you entered wrong username or password!")
count +=1
print("your username now locked!")