Unit 4 : Taking a vacation (question 1)


#1

Unit 4 (Functions) : Taking a vacation (question 1: Before we begin)

The exercise says:

Write a function called answer that takes no arguments and returns the value 42.
Even without arguments, you will still need parentheses.
Don't forget the colon at the end of the function definition!

When I submit the code it says the following:

Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: expected an indented block (python, line 2)

This is my code:

def answer():
return 24.

I am not very sure about where I have made a mistake.


#2

They want you to return the number 42 (without the period). You're returning 24. You got your digits mixed up :stuck_out_tongue:


#3

Oh, I see now, thanks. I did correct it, however it still says that there is a block:

File "python", line 2
return 42
^
IndentationError: expected an indented block


#4

Anything nested inside another needs to be indented. Python's indentation is very important:

def answer():
    return 42

#5

That was it, thank you. Now it's correct


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.