Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- secret_number = random.randint(1, 30)
- name = input("Hi there what is your name?: ")
- start = input(f"{name} do you want to play the guessing game? type yes or y to start: ")
- if start.lower() == "yes" or "y":
- print("Type a number between 1 - 30 you have 10 lives")
- lives = 10
- while lives >= 0:
- guessing = input("> ")
- if guessing == secret_number:
- print("You have guessed the right number")
- break
- elif lives == 0:
- print(f"You have lost the secret number was {secret_number}")
- lives -= 1
- else:
- print(f"Your life count is: {lives}")
- lives -= 1
- elif start.lower() == "no":
- print("The game ended")
- else:
- print("Invalid input")
Advertisement
Add Comment
Please, Sign In to add comment