I started learning python recently and I want to become more knowledgable and flexible with using loops.
My question is, let's say I created a list of names:
names = ('Benjamin', 'Damien', 'Dexter', 'Jack', 'lucas', 'Norman', 'Thorn', 'Bella', 'Blair', 'Ivy', 'Lilth', 'Megan', 'Rue', 'Sabrina', 'Samara', 'Anthea', 'Jessica', 'Igor', 'Luther', 'Boris', 'Abel', ) and now I want to use either a for loop or a while loop (I don't know which one is the best, but from my novice experience, I feel a for loop would work better but I can't find a solution) to generate random number and make my loop generate that amount of names.
This was my code but it doesn't work.
people_count = int(input("Enter how many names you wish to have, min 0, max 20: ")) for l in range(people_count): generate_random_names = random.choice(names) print (generate_random_names) and I only get one random name. What is missing/mistake here?
Thanks in advance!
generate_random_names, and after the code exits the loop you will print the lastgenerate_random_namesvaluenamestuple and assigning it to a variable again and again. Basically you're just getting the last value generated in the loop.