有人可以解释 random.randint(0, num_items -1) [关闭]的功能吗

问题描述 投票:0回答:0
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)
python list variables random integer
© www.soinside.com 2019 - 2024. All rights reserved.