0

What am I doing wrong here?

I wanted to make a list and and pick certain numbers within the list to show in Ordinal numbers (4th, 2nd, etc) and the rest to be just numbers, how can I skip a number to be printed twice with this code? li = list(range()) for i in li: if i == 1: print('1st') print(i) It prints 1st and 1, I want it to print 1st and the rest of the list.

17th Dec 2020, 5:07 PM
King
2 Antworten
+ 1
King you havn't provided arguments for range() function as per you need add the continue statement under the print("1st") inside if bock.
17th Dec 2020, 5:13 PM
Ratnapal Shende
Ratnapal Shende - avatar
0
Ratnapal Shende Thank you, that's is exactly what I was looking for. Jan Markus thank you, I learnt something new, now I don't have to type 1st, 2nd till eternity.
17th Dec 2020, 5:46 PM
King