Python guessing the age of the game

Source: Internet
Author: User

Guess the age of the game:

Game rules:

    1. Allow users to try up to 3 times
    2. After each attempt 3 times, if not guessed right, ask the user whether still want to continue to play, if the answer Y or Y, continue to let it guess 3 times, to reciprocate, if answer n or N, quit the program
    3. How to guess right, just quit.
1Age=182Count=True3  whileCount:4 5      forIinchRange (3):6Guess_age=int (Input ('guess how old my age is:'))7         ifGuess_age <Age :8             Print('guess small, go to Dali.')9         elifGuess_age >Age :Ten             Print('big guess, go to Little Li Chai.') One         Else: A             Print('Congratulations, you guessed it.') - exit () -     Else: theAns=input ('excessive number of errors, whether to continue: y/n-->:') -         ifAns = ='Y' orAns = ='y': -             Continue -         elifAns = ='N' orAns = ='N': +Count =False -         Else: +             Print('input error, resulting in direct exit') ACount = False
View Code

Python guessing the age of the game

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.