Today This Free Friday I am working on a project on YouTube a Number guessing game
import random
top_of_range = input("Type a number: ")
if top_of_range.isdigit():
top_of_range = int(top_of_range)
if top_of_range <= 0:
print('Please type a number larger larger than 0 next time.')
quit()
else:
print('Please type a number next time.')
quit()
- This part of the code for the number guessing game is to choice a number
while True:
guesses += 1
user_guess = input("Make guess: ")
if user_guess.isdigit():
user_guess = int(user_guess)
else:
print('Please type a number next time.')
continue
if user_guess == random_number:
print("You got it!")
break
else:
print("You got it wrong!")
print("You got it in", guesses, "guesses")
- This part of the code for the Number guessing game is the counting how much guesses did you guesses