##### Printing digits after the decimal point one by one
 Printing digits after the decimal point one by one uberman321 Unladen Swallow Posts: 1 Threads: 1 Joined: Oct 2020 Reputation: Oct-20-2020, 07:51 AM (This post was last modified: Oct-20-2020, 08:09 AM by uberman321.) 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. Reply bowlofred Da Bishop Posts: 1,156 Threads: 3 Joined: Mar 2020 Reputation: Oct-20-2020, 08:10 AM You could wrap your split-off string in a reversed(), or you could iterate over it backward. ```>>> for x in reversed(str(0.089).split(".")[1]): print(x) ... 9 8 0 >>> for x in str(0.089).split(".")[1][::-1]: print(x) ... 9 8 0``` Reply

 Possibly Related Threads… Thread Author Replies Views Last Post Single digits seem to be greater than double digits Frosty_GM 4 429 Nov-20-2020, 10:13 AM Last Post: DeaD_EyE connecting the first point to the last point Matplotlib omar_mohsen 0 1,480 Jan-15-2020, 01:23 PM Last Post: omar_mohsen testing for Decimal w/o importing decimal every time Skaperen 7 1,702 May-06-2019, 10:23 PM Last Post: Skaperen decimal point or comma Skaperen 8 1,989 Mar-17-2019, 06:02 AM Last Post: DeaD_EyE mixed decimal point characters Skaperen 1 886 Mar-10-2019, 05:23 PM Last Post: stullis I'm dividing large numbers of about 25 million digits I need to retain decimal format Pleiades 2 1,428 Apr-26-2018, 07:50 AM Last Post: Pleiades Add parameter to math.floor() to round to specific decimal point gabrield 2 1,301 Mar-09-2018, 08:43 PM Last Post: wavic decimal or hexadecimal digits to int Skaperen 3 2,284 Sep-26-2017, 07:03 AM Last Post: Skaperen Input a number with any number of digits and output it in reverse order of digits. sarada2099 6 4,026 Mar-12-2017, 05:45 PM Last Post: Ofnuts

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020