Skip to content
← Back to Community
Error from IDLE dunno what to do!!
Profile icon
VintageMind

How do you solve this guys TypeError: can only concatenate str (not "int") to str ??? I am quite new to Python programming so I need some help over here!

Answered by Bookie0 [earned 5 cycles]
View Answer
Voters
Profile icon
Bookie0
Profile icon
VintageMind
Comments
hotnewtop
Profile icon
Bookie0

So you have to add str before the variable.
For example:

variableA = 10 print(“I am “ + str(variableA) + “years old”)

Hope this helps!

Profile icon
VintageMind

@Bookie0 Thanks!!

Profile icon
VintageMind

@Bookie0 But what if my variable has input ? a = input()
It still gives me error this is my mini-program:

a = input()

print("The next number for the number" + str(a) + "is" + str(a + 1))

print("The previous number for the number" + str(a) + "is" + str(a - 1))

Profile icon
Bookie0

@Bitkoshy hmm the code seems fine, can you please show the repl? Thanks!

Profile icon
VintageMind

@Bookie0 Here is the screenshot:

Screen Shot 2020-06-03 at 10.08.29 am

Profile icon
Bookie0
Profile icon
VintageMind

@Bookie0 K will try now!

Profile icon
Bookie0

Tell me if it works! @Bitkoshy

Profile icon
VintageMind

@Bookie0 yep okay testing can we do multiplayer on another repl

Profile icon
Bookie0

No sorry I’m not available now. Did it work tho? If id did,

please mark my answers as the correct one! : )

@Bitkoshy

Profile icon
VintageMind

@Bookie0 pffff lol k i will later I am still working it out

Profile icon
Bookie0

Ok. Hope it works for you! Tell me if you need me, but Im going to sleep soon so maybe tomorrow @Bitkoshy

Profile icon
VintageMind

@Bookie0 If i make yours correct can you vote up for me??

Profile icon
VintageMind

@Bitkoshy That will be the deal hahahaha

Profile icon
Bookie0
Profile icon
Bookie0

Ok @Bitkoshy I did

Profile icon
Bookie0

Thanks for selecting my answer! 😊 @Bitkoshy

Profile icon
VintageMind

@Bookie0 I marked yours an the answer :) Have a goodnight! I am in Australia so yea morning for me!

Profile icon
Bookie0

Cool have a good day! @Bitkoshy

Profile icon
VintageMind

@Bookie0 Yea you too thanks!