Chockolates

 avatar
unknown
python
4 years ago
553 B
27
Indexable
import random

# Guessing number of chockolates in the box
choc_number = random.randint(1, 31)  # number 1-30

# grammar (is or are)
verb = 'are'
s = 's'
if choc_number == 1:
    verb = 'is'
    s = ''

# Create the loop
guess = int(input("How many chockolates are in the box?"))
while guess != choc_number:
    if guess < choc_number:
        guess = int(input("Too low! Try again "))
    elif guess > choc_number:
        guess = int(input("Too high! Try again "))

# Finish the game
print(f'You guessed it right. There {verb} {guess} chockolate{s}')
Editor is loading...