Skip to content Skip to sidebar Skip to footer

Float Required?? Error With Round() In Python

could not find this question answered by search. I am trying to learn some Python and need your help this this function: def roundtest(): i = round(raw_input('call a number: ')

Solution 1:

raw_input returns a string, which you then have to parse in to a float, like so:

def roundtest():
    i = round(float(raw_input("call a number: ")), 2)
    print i

Post a Comment for "Float Required?? Error With Round() In Python"