This is my first ever project. Please help me upgrade it.
print(“This project is about finding a random number between 1 and 100. Good luck!”) import random
Generate a random number between 1 and 100
random_number = random.randint(1, 100)
Loop until the user guesses correctly
while True: print(“Enter your guess, please:”)
# Get the user's guess and convert it to an integer user_guess = int(input()) # Compare the user's guess with the random number if user_guess < random_number: print("A little low, try again!") elif user_guess > random_number: print("A little too high, try again!") else: print("Good job! You guessed it!") break # Stop the loop when the correct number is guessed
submitted by /u/shoupapy
[link] [comments]
r/learnpython This is my first ever project. Please help me upgrade it. print(“This project is about finding a random number between 1 and 100. Good luck!”) import random Generate a random number between 1 and 100 random_number = random.randint(1, 100) Loop until the user guesses correctly while True: print(“Enter your guess, please:”) # Get the user’s guess and convert it to an integer user_guess = int(input()) # Compare the user’s guess with the random number if user_guess < random_number: print(“A little low, try again!”) elif user_guess > random_number: print(“A little too high, try again!”) else: print(“Good job! You guessed it!”) break # Stop the loop when the correct number is guessed submitted by /u/shoupapy [link] [comments]
This is my first ever project. Please help me upgrade it.
print(“This project is about finding a random number between 1 and 100. Good luck!”) import random
Generate a random number between 1 and 100
random_number = random.randint(1, 100)
Loop until the user guesses correctly
while True: print(“Enter your guess, please:”)
# Get the user's guess and convert it to an integer user_guess = int(input()) # Compare the user's guess with the random number if user_guess < random_number: print("A little low, try again!") elif user_guess > random_number: print("A little too high, try again!") else: print("Good job! You guessed it!") break # Stop the loop when the correct number is guessed
submitted by /u/shoupapy
[link] [comments]