def check(checked):
checked = {}
if checked == float:
return format(checked, '.2f')
else:
checked = "not a float"
return checked
# convert to float and check
a = input('Enter price for item 1 : ')
a = check(a)
b = input('Enter price for item 2 : ')
c = input('Enter price for item 3 : ')
d = input('Enter price for item 4 : ')
e = input('Enter price for item 5 : ')
print(a)
whenever I use input for a
and expect it to change it returns as not a float even when it has a decimal point. I am trying to get a number to a 2 decimal point limit and if it's not a float value to ignore it. I put the else
statement to see what's been going wrong I tried using is
instead of ==
but I still get the same result.