Thread: loops
View Single Post
Old May 1st, 2007, 5:25 PM   #5
ptmcg
Newbie
 
Join Date: Aug 2005
Location: Austin, TX
Posts: 15
Rep Power: 0 ptmcg is on a distinguished road
If you are looping for the purpose of building a list, read up on list comprehensions. Here is a quick way to build a list of the odd numbers up to 20:

print [c for c in range(20) if c%2 ]
ptmcg is offline   Reply With Quote