I'm making a piece of code that asks users to input their name and three scores into a program. This will continue happening within a while loop until it is stopped (meaning there could be 2 users entering scores or 50 depending on how many are entered). I want to append the user's name and the three scores for each into a list (each user being a unique list) but I don't know how to automatically create different list names. For example, something like user1, user2, user3 etc. would do, as long as there was the same number of lists as users that entered their name and scores. I hope this makes sense.
Asked
Active
Viewed 353 times
1
-
1This is a common question and the answer is: use a dictionary instead of plain variables. – Paulo Scardine Oct 28 '15 at 11:56
-
Could you link me to the original question please? – Daisy Bradbury Oct 28 '15 at 12:00
-
There are many questions like this: http://stackoverflow.com/questions/5036700/how-can-you-dynamically-create-variables-in-python-via-a-while-loop – Paulo Scardine Oct 28 '15 at 12:02
-
http://stackoverflow.com/questions/17685199/how-to-create-an-unknown-amount-of-variables-in-python?rq=1 – Paulo Scardine Oct 28 '15 at 12:02
-
1Also see the blogpost titled [_Why you don't want to dynamically create variables_](http://stupidpythonideas.blogspot.com/2013/05/why-you-dont-want-to-dynamically-create.html). – martineau Oct 28 '15 at 12:33