The control statement of L01-03:python Learning

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.