[Tutor] (no subject)

C or L Smith smiles at worksmail.net
Thu Sep 10 02:30:06 CEST 2009


>>>> What about range(0, -n, -1) ?
>>>> 
>>> That would need to have a starting value of -1 and an end value of
>>> -(len(phrase)+1).  Of else you can start at length - 1, end at zero
>>> and a step value of -1.
>> 
>> Another option, using "normal" range values but negative indexing is
>> 
>> for i in range(1,len(word)+1):
>>      print word[-i],
>> 

Or (and I'll duck after I pass on what I just happened across today on the web):

###
for i in range(len(word)):
    print word[~i]
###

/c


More information about the Tutor mailing list