Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ord()
#1
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
Reply
#2
Try
for i in range(104, 96, -1):
    print(chr(i))
BashBedlam and Men like this post
Reply
#3
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))
BashBedlam likes this post
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020