Forked from ZoeChiri/gist:7bd69b58a1f23cc082c550be014dc683
Created
October 2, 2019 23:53
-
-
Save mchirico/4e9351901ae1119b6d71525fe9c57cff to your computer and use it in GitHub Desktop.
Guess.py
This file contains 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 | |
numberOfGuesses = 0; | |
mysteryNumber = random.randint(1, 10) | |
while numberOfGuesses < 3: | |
guessUser1 = int(input("User1: Guess a number between 1-10: ")) | |
if guessUser1 < 0 or guessUser1 > 10: | |
print("Hey! That is an invalid number. You lost your turn. ") | |
if guessUser1 == mysteryNumber: | |
print("You win!") | |
break | |
if guessUser1 >= mysteryNumber: | |
print("Your guess is too high!") | |
if guessUser1 <= mysteryNumber: | |
print("Your guess is too low!") | |
guessUser2 = int(input("User2: Guess a number between 1-10: ")) | |
if guessUser2 < 0 or guessUser2 > 10: | |
print("Hey! That is an invalid number. You lost your turn. ") | |
if guessUser2 == mysteryNumber: | |
print("You win!") | |
break | |
if guessUser2 >= mysteryNumber: | |
print("Your guess is too high!") | |
if guessUser2 <= mysteryNumber: | |
print("Your guess is too low!") | |
numberOfGuesses = numberOfGuesses+1 | |
print("This is guess ", numberOfGuesses) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment