Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

ErinChristine

  • 3 years ago

I need some help with this piece of code! month=0 debt=5,000 payment=100 interest=73.50 while month<12: debt -= payment debt -= interest print debt It is telling me that -= is not valid. What am I doing wrong.

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

    Read the error message the interpreter is giving you closely. The clue you need is in there.

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

    debt = 5,000 # wrong debt = 5000 # right

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

    a la python shell you are creating a tuple and then trying to += (concatenate) an int to it >>> debt=5,000 >>> debt (5, 0) >>> debt+=100 Traceback (most recent call last): File "<pyshell#253>", line 1, in <module> debt+=100 TypeError: can only concatenate tuple (not "int") to tuple as rsmith said above, get rid of the ','

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

    Don't forget that you never increase the value of month, your loop is endeless, never separate the numbers, only if they are floats. Remember also that, the interest are part of your payment, should be better if it looks like this: debt = debt - (payment+interest), that'll help if they ask you things like, total amount you paid.

  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