Can someone help me understand this issue?

Hi there. I just got my Codewars account to start working on my Python basic skills. For the first challenge, I’m asked to "Make a simple function called greet that returns the most-famous “hello world!”

So I wrote the following code:

def greet():
print(“Hello world!”)

greet()

But this code doesn’t solve the test. It says:
“‘Greet’ (the function) doesn’t return hello world!: None should equal ‘hello world!’”…

So what is the issue? because I can’t see it…
I have run this code on Pycharm and it returned “Hello world!”

Advice…

The challenge asks for “hello world!” as return value, so put it in return statement instead of print it out.

Hi Fish… :tropical_fish: :smile:
It looks like you are on the right track, :+1: But I have question.

Q. Is the code in your function shown exactly as above or did you use indentation?
BTW, You don’t always need the ‘return’ command, indentation is key. I usually like 4 spaces.
HTH
:sunglasses:

Like:
def greet():
…‘4spaces’ print(“hello”)

I think this error message implies the testing code is expecting a return value. The function does not have return statement, so it’s return value is None, and therefore the message says “None (the return value) should equal ‘hello world!’”.

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