-1

I am getting following error.

enter image description here

2
  • use print(type(1)) to check what was entered into the input field, where '1' is what was entered. you have entered a piece of code instead of number
    – gremur
    Mar 20, 2022 at 8:02
  • 1
    Don't copy/paste your code to the interpreter when you have input in your code else the next line of code (here m1 = ...) is used as the input.
    – Corralien
    Mar 20, 2022 at 8:05

1 Answer 1

0

When you run the interpreter like this and call the input() function, it asks for your input immediately (since it will execute the first line before it even interprets the second line). Then when you paste in the second line, it will think that that's the input it's expecting and crash since it can't convert the string "m1 = int(input('Enter the number of compounding periods for Bank 1'));"

This is why you should usually edit your code in a Python file (.py) rather than typing it line by line in the interpreter, since there is no risk of your code being interpreted as input.

Also keep in mind that you don't need semicolons in Python, and don't forget to indent your if and else statements.

In future, you might also want to learn to read error messages, since they are extremely helpful for figuring out what's gone wrong.

Not the answer you're looking for? Browse other questions tagged or ask your own question.