三次登陆
_user = "aa" _passwd = "123456" count = 0 while count < 3: #当这个条件成立时,执行下面代码 username = input(‘enter username:‘) password = input(‘enter password:‘) if username == _user and password == _passwd: print(‘welcome %s login‘% _user) break #终止,跳出 else: print(‘username or password is wrong‘) count += 1 if count == 3: count_going = input(‘还想继续吗?[y/n]:‘) if count_going == ‘y‘: count = 0 else: print("输入次数太多了!!!")
九九乘法表
x = 1 while x <=9: y = 1 while y <= x: print(str(x)+‘*‘+str(y)+‘=‘,x*y,end=‘\t‘) y +=1 print() x +=1
时间: 2024-12-26 16:26:37