So I'm trying to round a float to two decimal places, which works fine if there's more, but otherwise breaks.
Anyways here's what I have:
income=input("Enter your expected annual income in USD.")
if floatcheck(income) == True:
Income=float(income)
income=str(round(Income, 2))
So I'm trying to either: always have it be two decimal places (which works fine if there is more than that, but if it is a whole number it will actually add a .0 which looks weird with currency), or have whole numbers not have any decimals at all. I tried a ton of different things like making it round to 3 and hoping that would add another 0, and adding +0.00 Oh, and I already defined floatcheck above as:
def floatcheck(str):
try:
float(str)
return True
except ValueError:
return False
Anyways I assume this is super easy to solve, but I cant seem to figure it out anywhere.