Nov-29-2020, 05:49 PM
Hi
I am going through the Python Crash Course book, and answering the questions in each chapter.
I'm stuck at one.
The question is:
1. Create a list of numbers from 1 - 9
2. Loop through the list and using if-elif-else the output should read "1st 2nd 3rd" etc with each result on the new line.
So I did this:
I then created a for loop to go through each number. I tested '1' but that doesn't seem to work.
Any ideas?
I am going through the Python Crash Course book, and answering the questions in each chapter.
I'm stuck at one.
The question is:
1. Create a list of numbers from 1 - 9
2. Loop through the list and using if-elif-else the output should read "1st 2nd 3rd" etc with each result on the new line.
So I did this:
numbers_list = list(range(1,10)) print(numbers_list) for number in numbers_list: if number == '1': print(f"{number}st")I printed the list as soon as I created it to make sure that was ok, which it was.
I then created a for loop to go through each number. I tested '1' but that doesn't seem to work.
Any ideas?