Completed 5-11 Ordinal Numbers
This commit is contained in:
parent
52e22103bc
commit
637a5ac11b
20
Chapter_05/5-11_ordinal_numbers.py
Normal file
20
Chapter_05/5-11_ordinal_numbers.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Exercise 5-11 Ordinal Numbers
|
||||||
|
# Learning Objective: Iterations in a list.
|
||||||
|
|
||||||
|
nums = []
|
||||||
|
|
||||||
|
for num in range(1,10):
|
||||||
|
nums.append(num)
|
||||||
|
|
||||||
|
print(nums)
|
||||||
|
|
||||||
|
for num in nums:
|
||||||
|
if num == 1:
|
||||||
|
print(str(num) + "st")
|
||||||
|
elif num == 2:
|
||||||
|
print(str(num) + "nd")
|
||||||
|
elif num == 3:
|
||||||
|
print(str(num) + "rd")
|
||||||
|
else:
|
||||||
|
print(str(num) + "th")
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user