Created
September 30, 2015 00:21
-
-
Save Maddix/4177bc1c38b3b34e040f to your computer and use it in GitHub Desktop.
Python version of guess my number game. 17 lines long, though one could make it 15 lines long by removing the win variable and the user = int(user).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| num = random.randint(0, 100) | |
| win = False | |
| print("Guess my number game!") | |
| while not win: | |
| user = input("> ") | |
| if user.isdecimal(): | |
| user = int(user) | |
| if user > num: | |
| print("To High!") | |
| elif user == num: | |
| print("Win!") | |
| win = True | |
| else: | |
| print("To Low!") | |
| else: | |
| print("Numbers Only!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment