Code: Select all
import random
def main():
num = random.randint(0, 100)
score = 0
print("Guess the Number")
def question_1():
global score
try:
guess_1 = int(input(""))
if num < guess_1:
score = score + 1
print("The Number is Smaller")
question_1()
if num > guess_1:
score = score + 1
print("The Number is Bigger")
question_1()
if num == guess_1:
score = score + 1
print(f"Congratulations you found the Number within {score} Attempts")
play()
except:
print("please enter a Number")
question_1()
def play():
again = input("Would you like to play again? ")
if again == "Yes":
print("Guess the Number")
main()
if again == "No":
quit()
else:
print("Please use Yes or No")
play()
question_1()
main()
Mobile version