r/learnpython • • 18m ago

My first complete comand in Python, from my first day on:

Look:

import random
import time

def drawn(a, b):
    return random.randint(a, b)
answer = 'yes'

while answer == 'yes':
    a = int(input('Min number: '))
    b = int(input('Max number: '))
    print(f'Drawn: {drawn(a, b)}')

    time.sleep(2)

    answer = input('Try again? ').lower()

This creates a random number generator where you can choose the minimum and maximum numbers!

5 Upvotes

2 comments sorted by

•

u/fazzah PyQt | SQLAlchemy | ReportLab 9m ago

good. now find a way to protect the script if someone inputs "foo"