Python Forum

Full Version: ord()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

Quick question. coding in python...How do you continuously decrease an ord value until it reaches an n value?

for example: i have a ord value of 104 which is 'h' and want to move and change it to the previous letter g then loop back change g to f until I reach 97 which is 'a'.

Thx in advance for your help.

Cheers
Try
for i in range(104, 96, -1):
    print(chr(i))
Thanks a lot that works great...now I have to figure out how to place it in a variable.
Cheers,

(Jan-12-2022, 06:46 AM)Gribouillis Wrote: [ -> ]Try
for i in range(104, 96, -1):
    print(chr(i))