Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Newbie Please
#5
Ty very much for feedback I really appreciate it. I also been trying to figure this out, I am so stuck again trying to add ordinal suffix to numbers. I just can't figure it out. Ive searched and searched the web and what i find is way over my head. Any feedback on this would help so much again. Thank you.
ord_nums = ['1','2','3','4','5','6','7','8','9']
suffix = ['st','nd','rd','th']

for suffix in ord_nums:
    if ord_nums < 2:
        print (str(ord_nums) + 'st')
    elif ord_nums < 3:
        print (str(ord_nums) + "nd")
    elif ord_nums < 4:
        print (str(ord_nums)  + "rd")
    elif ord_nums > 4:
        print (str(ord_nums) + "th") 
        break
Reply


Messages In This Thread
Help Newbie Please - by JJG - Dec-01-2017, 05:12 AM
RE: Help Newbie Please - by Larz60+ - Dec-01-2017, 06:25 AM
RE: Help Newbie Please - by buran - Dec-01-2017, 07:54 AM
RE: Help Newbie Please - by Larz60+ - Dec-01-2017, 10:25 AM
RE: Help Newbie Please - by JJG - Dec-02-2017, 02:57 AM
RE: Help Newbie Please - by JJG - Dec-02-2017, 04:06 AM
RE: Help Newbie Please - by Larz60+ - Dec-02-2017, 07:24 AM
RE: Help Newbie Please - by JJG - Dec-06-2017, 02:44 AM

Forum Jump:

User Panel Messages

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