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! While you're at it, check out some resources Treehouse students have shared here.

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

Python Python Basics (Retired) Things That Count Ints & Floats

asks to turn string '3' into an integer.. my answer is -- input_int = '3' -- why is this wrong?

?

1 Answer

Chaz Watkins
Chaz Watkins
9,879 Points

You are assigning the string version of 3 as '3' to the variable input_int. Doing this does not make the string an integer. To make the number string an integer, you can use int('3') or input_int = int('3').

This tells python that this string needs to be converted to an integer. In reverse you can also make an integer a string with str(3).

Hope this helps!