Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python loop through a range of variables [closed]

Tags:

python

I have a number of variables iE: x1 to x10

Now I'd like to get the content of each of them.

Is it possible to put the variable together like xi? Or should I just use Lists?

Kind of lost on the Syntax here I believe! Something like that is what im thinking of:

while i <= 10:
    print(test+i)
like image 496
Jrc Avatar asked Mar 29 '13 13:03

Jrc


1 Answers

variables = [x0, x1, x2, x3, x4, x5, x6, x7, x8, x9]
for x in variables:
    print x
like image 155
Ioan Alexandru Cucu Avatar answered Oct 22 '22 13:10

Ioan Alexandru Cucu