I am just starting coding, and this is my attempt at the famous number-guessing game. Any and all feedback and criticism is greatly appreciated.
print(" Welcome to the number guessing game")
play_game = True
while play_game:
import random
random_integer1 = random.randint(0, 50)
random_integer2 = random.randint(random_integer1+5, 100)
print("Your number are between ", random_integer1, random_integer2)
random_integer = random.randint(random_integer1, random_integer2)
running = True
while running:
number = int(input("what is your guess?"))
if number == random_integer:
running = False
print("Correct first try")
if number != random_integer:
if number > random_integer:
print(" Too high, guess again")
if number < random_integer:
print(" Too low, guess again")
number = int(input("what is your guess?"))
redemption = True
while redemption:
count = 1
guess_count = 1
while count < 11:
if number != random_integer:
count += 1
guess_count += 1
if number > random_integer:
print(" Too high, guess again")
if number < random_integer:
print(" Too low, guess again")
if count == 10:
coward_protocol = input("do you want to give up? (y/n)")
if coward_protocol == 'y':
redemption = False
running = False
print("Goodbye Coward")
break
else:
count -=10
number = int(input("what is your guess?"))
if number == random_integer:
redemption = False
running = False
print("Correct, only took you", guess_count+1, "tries!")
break
play_again = input(" Do you want to play again? (y/n)")
if play_again == 'y':
play_game = False
play_game = True
else:
print("Have a good day!")
break