Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

minimallinux

  • 3 years ago

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

  • This Question is Closed
  1. Daire
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  2. minimallinux
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Python

  3. Daire
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  4. pdpinch
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

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

  5. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy