On Sat, Mar 7, 2015 at 10:39 AM, elie khairallah <eliekhairallah1...@gmail.com> wrote: > hello , I would like to know if theres a way to change a variable's name > after every iteration for example I want to make a function that stores a > number in x_1 if i=1 and in x_2 if i=2. > To be more precise: > i=1 > def f(n): > while i<n: > x_i = i**2 ##this writing is wrong I would like here to have > x_1 or x_2 ... > (depending on i) > return (x_1,x_2,x_3 .....) > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor
You could certainly use I as an index into a list called x. This doesn't look like a good idea though -- Joel Goldstick http://joelgoldstick.com _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor