Requirements:
1, accept user input;
2, judge whether the user is Alex, if not re-accept input;
3, determine whether the user Alex Password is 11111, if not re-enter;
The code is as follows:
Input=raw_input ("Your name:") while true: if input== ' Alex ': print "Welcome alex" password = raw_input ("Your password:") p= ' 111111 ' while True: if password==p: print ' Your password is ok.loging! ' break else: print "Its woring.again:" password = raw_input ("Your password:") break else: print "Sorry ,its not you " input=raw_input (" Your name: " )
See the above code, and find that there are still several redundant parts, modified as follows:
While true: input=raw_input ("Your name:") if input== ' Alex ': print "welcome ",input while True: password = raw_input ("Your password : ") p= ' 111111 ' if password==p: print ' your password is ok.loging! ' break else: print "Its woring.again:" break else: print "Sorry ,its not you"
I am a beginner, welcome seniors, friends come to guide, thank you!
This article is from the "Emperor Heart Zen Shadow" blog, please be sure to keep this source http://yedee.blog.51cto.com/513852/1548015
The control statement of L01-03:python Learning