I'm taking an intro to Python and I'm asked to request an input of dimes and quarters and then add the values, I'm trying to restrict either the input to a second decimal for the dimes.
dimes = input('How many dimes do you have?: ') dimes = round(dimes, 2)
It's supposed to take an input and put it to the second decimal:
input = 5 output = 0.05
What it's doing:
dimes = round(dimes, 2) TypeError: type str doesn't define __round__ method
You simply need to convert the input to an integer and divide it by 100.
dimes = int(input('How many dimes do you have?: ')) / 100
This will fail if the user enters something that is not an integer.
2.1m questions
2.1m answers
60 comments
57.0k users