decimals are present?
Like 252.2292312 should be rounded to 252.23, but 222.0 should be rounded to 222
Hmm, you're mixing types.
def stupeed_round(number: int | float) -> int | float: if (number - int(number)) == 0: return int(number) return round(number, 2) It works, I guess
you want an overload here
Why not just use round, and convert the value to int just when an int is expected (like in a range)
I need to convert number to words, like 101.1 becomes one hundred one dollars and ten cents 101.0 becomes one hundred one dollar and 0 cents So I need 101.0 to become 101
And what's the problem with one hundred dollar and 0 cents? Oh, well
You don't write like this in financial reports
there are some libraries for python for dealing with currency/money.
oh, I never thought about that
Обсуждают сегодня