Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 16 Online
OpenStudy (anonymous):

I am getting a type error 'cannot concatonate 'str' and int objects' for balance = 5000 print 'Month 1 Balance = ' + balance Any tips ?

OpenStudy (anonymous):

You'll need to convert your int to a String before you print it as part of another String. What language are you using?

OpenStudy (anonymous):

Python

OpenStudy (anonymous):

Ok. Im not really familiar with Python but try using the str() function. Try : print 'Month 1 Balance = ' + str(balance)

OpenStudy (pdpinch):

Daire is right, but another common solution is to use a comma instead of the + print 'Month 1 Balance =', balance

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!