Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Cannot convert to integers
Earlier in the video, Kenneth said that we can convert float to integer by using the int() function and put the floats into it e.g: int(2.54) will be converted to 2
But, when I enter decimal number when input_int being asked, it shows this error:
Traceback (most recent call last):
File "string_multiply.py", line 4, in <module>
ValueError: invalid literal for int() with base 10: '2.54'
Does anyone has any explanation about this? Thank you! :)
Jesse Pavlis18,088 Points
The issue here is that the
input_int variable is a string, not a float. Try