455,767 Members | 1,375 Online
Need help? Post your question and get tips & solutions from a community of 455,767 IT Pros & Developers. It's quick & easy.

# for loop question

 P: n/a hi.. basic foor/loop question.. i can do: for a in foo print a if i want to do something like for a, 2, foo print foo where go from 2, to foo.. i can't figure out how to accomplish this... can someone point me to how/where this is demonstrated... found plenty of google for for/loop.. just not this issue.. thanks -bruce Jul 6 '06 #1
4 Replies

 P: n/a just do: for a in range(2, foo+1): print a range(a, b) gives [a, a+1, a+2, ..., b-2, b-1] bruce schrieb: hi.. basic foor/loop question.. i can do: for a in foo print a if i want to do something like for a, 2, foo print foo where go from 2, to foo.. i can't figure out how to accomplish this... can someone point me to how/where this is demonstrated... found plenty of google for for/loop.. just not this issue.. thanks -bruce Jul 6 '06 #2

 P: n/a On 2006-07-06, Daniel Haus i can do: for a in foo print aif i want to do something like for a, 2, foo print foowhere go from 2, to foo.. just do: for a in range(2, foo+1): print a Except that in the OP's example foo was a sequence, not an integer. I think. -- Grant Edwards grante Yow! You can't hurt at me!! I have an ASSUMABLE visi.com MORTGAGE!! Jul 6 '06 #3

 P: n/a Except that in the OP's example foo was a sequence, not an integer. I think. Yes, possibly. But then, what's "from 2 to foo"? this way it might be for a in [2] + foo: print a Jul 6 '06 #4

 P: n/a for a in range(2, len(foo)): print a or maybe you need for a in range(1, len(foo)): print a ? York bruce wrote: hi.. basic foor/loop question.. i can do: for a in foo print a if i want to do something like for a, 2, foo print foo where go from 2, to foo.. i can't figure out how to accomplish this... can someone point me to how/where this is demonstrated... found plenty of google for for/loop.. just not this issue.. thanks -bruce Jul 6 '06 #5

### This discussion thread is closed

Replies have been disabled for this discussion.