Oct-20-2020, 07:51 AM
I recently began learning Python and I am trying to write a program in which I print the digits after the decimal point one by one once the user enters a non-integer value.
So far I have this:
for x in str(num).split(".")[1]:
print(int(x))
With this, if num = 0.089 as an example, it would give me:
0
8
9
However, I want it like this:
9
8
0
How should I change my code? Thanks.
So far I have this:
for x in str(num).split(".")[1]:
print(int(x))
With this, if num = 0.089 as an example, it would give me:
0
8
9
However, I want it like this:
9
8
0
How should I change my code? Thanks.