more newbie help needed
bruno at modulix
onurb at xiludom.gro
Tue Nov 15 09:16:20 CET 2005
Steve Holden wrote:
> john boy wrote:
>> using the following program:
>> fruit = "banana"
>> index = 0
>> while index < len (fruit):
>> letter = fruit[index-1]
>> print letter
>> index= index -1
>> this program is supposed to spell "banana" backwards and in a vertical
>> patern...it does this....but after spelling "banana" it gives an error
> Note, however, that there are more pythonic ways to perform this task.
> You might try:
> for index in range(len(fruit)):
> letter = fruit[-index-1]
> print letter
> as one example. I'm sure other readers will have their own ways to do
> this, many of them more elegant.
let's see... what about:
for c in reversed(fruit): print c
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