use an if-elif-else chain inside the loop to print the proper oridinal ending for each numbers.your output should read 1st 2nd 3rd 4th 5th 6th 7th 8th 9th, and each result should be an separate line. what wrong i am doing please let me know ?
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for numb in numbers:
if numb == 1:
print(f"{numb}st")
elif numb == 2:
print(f"{numb}nd")
if numb == 3:
print(f"{numb}rd")
else:
print(f"{numb}th")
Aucun commentaire:
Enregistrer un commentaire