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

Blair Murphy
Blair Murphy
12,367 Points

Python Basics - Things that count quiz question

Hi,

This is driving me nuts. I've passed the quiz, however, I keep retaking it because I want to know what the correct answer is and absolutely nothing I input is correct. The question goes:

Complete the following to make my string into an integer: my_int = __________ ('3')

And now, how would we convert an integer into a string? my_str = __________ (3)

Can somebody please help?

Thanks!

2 Answers

Josh Keenan
Josh Keenan
19,652 Points

To convert a string to an integer in Python, we use the int() funtion.

So to answer the first question, you should put 'int' (without the quotation marks though!) in the blank before the bracket, this converts the string '3' to the number 3.

To then convert the integer of 3 to the string of '3', it's almost the exact same; using the str() function, like in the first question, you must put 'str' in the blank (without the quotation marks again). This lets Python know you want to convert the integer to a string.

Blair Murphy
Blair Murphy
12,367 Points

Thanks Josh! I really appreciate your help!

Josh Keenan
Josh Keenan
19,652 Points

Anytime, good luck with Python, it's the best to start with and then realise you won't ever find anything better....