Quick actions

cmd+k|ctrl+k

Navigation

Languages

random game in Python

Snippet info

Language

Python

Visibility

public

Author

miffyying621

Created

2025-04-07T09:44:43.781379Z

Updated

2025-04-07T09:44:43.781379Z

import random
#options = ("rock", "paper", "scissors")
#number = random.randint(1,6)

#option = random.choice(options)
#print (option)

low = 1
high = 100
guesses = 0
number = random.randint(low, high)

while True:
    guess = int(input(f"Enter a number between ({low} - {high}): "))
    guesses +=1
    
    if guess < number:
        print(f"{guess} is too low")
    elif guess > number:
        print (f"{guess} is too high")
    else: 
        print(f"{guess}is correct")
        break
    
print (f"This round took you{guesses} guesses")
INFO