While loop - print several times but on 1 line.

bruno at modulix onurb at xiludom.gro
Thu Jan 26 08:07:04 EST 2006


Jeffrey Schwab wrote:
> Danny wrote:
> 
>> Great! It's been solved.
>>
>> The line, as Glaudio said has a "," at the end and that makes it go
>> onto one line, thanks so much man!
>>
>> var = 0
>> while <= 5:
>>     print a[t[var]],
>>     var = var +1
>> prints perfectly, thanks so much guys.
> 
> 
> 
> Looping over indexes is kinda unpythonic in its own right.  Is there
> something magical about the number 5?
> 
>     for e in t:
>         print a[e],

Or if you want to just iterate over a part of t:
  start = 0
  end = 6 # end is not included
  for e in t[start:end]:
    print a[e]*



-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list