by CodeChum Admin
Manipulating values from a series of numbers is fun, but let's try exploring the use of loops a little more.
How about printing out each digit of a number starting from its rightmost digit, going to its leftmost digit?
Instructions:
Input
A line containing an integer.
214
Output
Multiple lines containing an integer.
4
1
2
while True:
num = int(input("Input a positive integer: "))
if(num<=0):
print("Number out of range")
continue
else:
break
digit_string = str(num)
digit_map = map(int, digit_string)
digit_list = list(digit_map)
print(digit_list)
for i in range(len(digit_list)):
print(digit_list[-1-i])
Comments
Leave a comment