how to reverse a string number in python with for loop

num = '123456789'

for i in num[::-1][::2]:
    print(i)

Output –

9
7
5
3
1

Leave a Comment