How to increment variable names/Is this a bad idea
Posted
by tom
on Stack Overflow
See other posts from Stack Overflow
or by tom
Published on 2010-03-21T19:43:35Z
Indexed on
2010/03/21
19:51 UTC
Read the original article
Hit count: 526
In Python, if I were to have a user input the number X, and then the program enters a for loop in which the user inputs X values, is there a way/is it a bad idea to have variable names automatically increment?
ie:
user inputs '6'
value_1 = ...
value_2 = ...
value_3 = ...
value_4 = ...
value_5 = ...
value_6 = ...
Can I make variable names increment like that so that I can have the number of variables that the user inputs? Or should I be using a completely different method such as appending all the new values onto a list?
© Stack Overflow or respective owner