python_while_if_break

2018-04-24  本文已影响0人  david_6522

要求:输入用户名和密码,超过三次不正确退出

#!/usr/bin/env python

# -*- coding: utf-8 -*-

name ='david'

passwd ='haodf666'

count =0

while count <3:

    n =input("please input your name: ")

    p =input("please input your password: ")

    if name == nand passwd == p:

        print("welcome to U")

        break

    else:

        print("__your name or passwd is wrong__")

        count +=1

else:

        print("###### you tried too many times .good bye ######")

上一篇下一篇

猜你喜欢

热点阅读