Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
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