Is there a way to "automatically" create a certain number of instances of a class in Python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is there a way to "automatically" create a certain number of instances of a class in Python?

Hey there, I wrote a program to distribute presentation/essay topics to a certain number of students based on their first priority topic, second priority topic and one topic they don't want to have at all. I started out with a class named students because at that point I figured it would be a good way to store the name, priority values and the resulting topic of the student. The program works for my sample of five students (and five topics) now but I'd like to extend it to a variable number of students, preferably without having to enter every student by hand but for example creating as many students (instances) as there are in my name list, but I can't seem to be able to find a solution how to do that that actually works (I don't mind if you tell me that was a ridiculous way to write the program in the first place, it was the first project I made up on my own😅).

27th Oct 2019, 7:18 PM
ninkelea
3 Answers
+ 1
~ swim ~ (i for i in x) is not a tuple.
27th Oct 2019, 8:43 PM
Seb TheS
Seb TheS - avatar
+ 1
~ swim ~ thanks, I'll try tomorrow :)
27th Oct 2019, 9:42 PM
ninkelea
0
These are crucial classes and educational resources. Right now, I'm using this website to help me with my letter of recommendation https://www.lorservice.com/letter-of-recommendation-for-internal-medicine-residency/ This is a crucial time, therefore I'm determined to be well-prepared. This will, after all, affect my chances of getting a scholarship.
19th Oct 2023, 10:56 PM
Gary Stokley
Gary Stokley - avatar