0

I need to make following string:

amount = "163,852ドル.06"

Like this:

16385206000

How can I do it, like I am following this method,:

money = "163,852ドル.06"
original_amount = ('').join(money[1:].split(','))
print(int(float(original_amount)))

But it is returning me:

163852
asked Mar 23, 2022 at 14:21
2
  • 1
    16385206000 doesn't look like what it should be. Commented Mar 23, 2022 at 14:23
  • int(float(amount[1:].replace(',','')) * 100000) Commented Mar 23, 2022 at 14:24

2 Answers 2

1
>>> int(''.join(c for c in amount if c.isdigit()))*1000
16385206000
answered Mar 23, 2022 at 14:27
Sign up to request clarification or add additional context in comments.

Comments

0

It's because you're casting a floating point to an integer value, which rounds to the nearest full number. To achieve the value 16385206000, you could use int(float(original_amount) * 100000).

answered Mar 23, 2022 at 14:25

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.