mardi 14 mars 2023

Can some one explain the functionality of random.randint(0, num_items -1) [closed]

import random
names_string = input("Give me everybody's names, separated by a comma. ")
names = names_string.split(", ")

#Get total number of items in list
num_items = len(names)


random_choice = random.randint(0, num_items -1)

person_who_will_pay = names[random_choice]
print(person_who_will_pay + " is goin to by the meal today.")

random_choice = random.randint(0, -1)



Aucun commentaire:

Enregistrer un commentaire