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 Basic Numbers

sadik salad
sadik salad
1,916 Points

am getting error even tho my scripts its similar to the teacher one

File "string.py", line 3, in <module>
TypeError: Can't convert 'int' object to str implicitly

5 Answers

Misha Shaposhnikov
Misha Shaposhnikov
8,718 Points

Don't use the int() function on "input_int" because this returns an integer which you are trying to directly concatenate with input_String and Python can't do that. Since input_int is already a string since that is what the input() function returns, you can just do this:

print(input_String + input_int)

Happy Coding! =)

Hannah McFarlane
Hannah McFarlane
2,810 Points

I got the same error as sadik's when I ran my code. I think I made the same mistake: used the + operator instead of a *.

My solution was changing my print line to print(input_string*int(input_int))

This worked. (and I put my glasses on after that.)

Misha's example I think would return Hello3 rather than the HelloHelloHello you'd be after.

wei du
wei du
2,569 Points

so I have a different issue:

below is my code:

input_string = input("What string do you want to use?")

input_int = input("How many times should I repeat it?")


and I can run through the first part fine, until I need to put in an integer , then here is the message I received: name 'input_string' is not defined.

The only thing I can see differently when I type the code in the workspace is the * (shift + 8) sign, when the video type in the sign, it turned to orange color, however, when I did it, the sign did not turn...

anyone can check my code please?



wei du
wei du
2,569 Points

never mind, I find out my problems: I need to type in space behind the input_string and input_int.

I also had this issue. My code was correct but for some reason it didn't work without a linebreak between the first and second input strings. (hope I said that right...)

there is no plus sign it is a star