0
Random selection from a list - is there a better way?
Very new to Python and interested in writing a random name generator my current project. This was what first came to mind. Is there a more efficient way to achieve the same results? I feel like I might be missing something simple... names = ["Tom", "Harry", "Melissa", "Andrew", "Stacy", "Jack"] name_choice = random.randint(0, (len(names)-1)) print(names[name_choice])
2 Antworten
0
Exactly what I was after. Thank you!