mardi 21 septembre 2021

How can I make a function in Python that prints random integers between 10 and 20, and stops when the value of 20 is obtained?

I am trying to make a function in Python that generates random numbers using the random.randrange() function. I need it to print a set of integers in no specific order from 10 to 20, until it stops at when a value of 20 is obtained. I've attached my code of what I have tried.

import random

def number_function():
    my_number = random.randrange(10,21)

    if (my_num == 21):
        print(my_number)
    else:
        #(not sure here)
        
def main():
    number_function()
    
main()



Aucun commentaire:

Enregistrer un commentaire