5.2, Step #4 - error in given code?


#1

Here’s what the text in the editor looks like - I only added the bold code, indented, on line #2. The rest of the text was provided / given.

def calculate_interest(principal):
return principal * (1 + .04 / 12) ** 12
deposit = float(input(“What amount of money did you deposit? Just enter the number, please.”))
print(calculate_interest(deposit))

Looking at Step #5, it appears my code is correct, however, I’m getting the following error after running it?

File “main.py”, line 6
deposit = float(input(“What amount of money did you deposit? Just enter the number, please.”))
^
IndentationError: expected an indented block

KeyboardInterrupt


#2

True, for functions, Python requires an indent, ie:

def product():
return (x * y)


#3

Thanks for the reply. It was indented in my code, but was still showing an error for an altogether different line. I think replit is having difficulty in Discovery / in my browser (Chrome), so I’m copying / pasting all code over to the replit site and running the code there and all is working well. When using replit via the Discovery course pages, it’s not saving/updating properly.


#4

I’m getting the same error message. Even on repl.it! I’ve reworked this so many times. I’ve moved it. Indented it (even up to 4 indents lol) renamed it. added it into the function definition. I’ve done everything I can think of. For 2 days!! It doesn’t matter what I do or what line I move it to. It still says the same error message and it still says it’s line 6 even if I move it to line 2 or 5. Doesn’t matter. I’m not sure if it’s my error or a Discovery error


#5

I’ve run into this issue in multiple steps/activities. Here is the workaround that I’ve found:

  1. Open the Debugger from the left side menu (the 3 button from the top, which looks like >| ) and
  2. Start debugging.
  3. The execution will stop at the 1st line of your code. Click resume to continue.

Module 4.3 step 10 help please
#6

Thank you. I will try this.