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
Working with ints and floats in python
Hi guys I'm working on the ints and floats section of python with Kenneth Love. In one of his examples under "the things that count section, Basic numbers video" he is using the print function to print the input string + the int version of input in. the code was as follows...
input_string = input("what string do you want to use? ") input_int = input("How many times should I repeat it? ")
I thought this code should repeat the int or whole number but instead I keep getting an error message that reads... TypeError : Can ’t convert ‘int’ object to str implicitly.
I dont understand why this code won't take. Anyone else having an issue with this?
Tara Edwards6,521 Points
Short answer: You should put in
The code has a "+" rather than a "*". So the interpreter assumes that you are joining variables together. Since Python can only join variables of the same type (string with string, list with list), the programmer gets an error message.
"*" is used as a multiplication operator in this sense. The interpreter gets "print this string this many times".
I hope that helps.