Guest User

Untitled

a guest
Jun 1st, 2022
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. import random
  2. secret_number = random.randint(1, 30)
  3.  
  4. name = input("Hi there what is your name?: ")
  5. start = input(f"{name} do you want to play the guessing game? type yes or y to start: ")
  6. if start.lower() == "yes" or "y":
  7.     print("Type a number between 1 - 30 you have 10 lives")
  8.     lives = 10
  9.     while lives >= 0:
  10.         guessing = input("> ")
  11.         if guessing == secret_number:
  12.             print("You have guessed the right number")
  13.             break
  14.         elif lives == 0:
  15.             print(f"You have lost the secret number was {secret_number}")
  16.             lives -= 1
  17.         else:
  18.             print(f"Your life count is: {lives}")
  19.             lives -= 1
  20.  
  21. elif start.lower() == "no":
  22.     print("The game ended")
  23. else:
  24.     print("Invalid input")
  25.  
Advertisement
Add Comment
Please, Sign In to add comment