Python Forum

Full Version: Exercism with Python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello

This is my first post on this forum
I am new to Python and programming

I would like to do the first exercise on exercism, The Hello World exercise
but when I follow the coding pattern, it just doesn't work, I do it on their online editor,

Is here anyone has experienced the same issue?

Thank you very much
so what does your code look like?
Please post.
Hello

Thank you very much for your kind reply


Here is my code is under the hash signs,

def hello():
    print("hello world")
    return 'Goodbye, Mars!'

########
Print (Hello World)
Print should be all lower case and you need to call the function hello
def hello():
    print("hello world")
    return "Goodbye, Mars!"


########
print(hello())
Output:
hello world Goodbye, Mars!
Hello

I got the message on the screenshot,
kindly check it

thank you
What does the test says it expects your function to return, compared to what you have actually returned?
Do you understand the difference between printing and returning?
No I Don't know what is the difference between two these,
could you explain to me please?
Thanks





(Mar-17-2022, 06:57 AM)ndc85430 Wrote: [ -> ]Do you understand the difference between printing and returning?
When you return a value from a function, it can be used in subsequent parts of the program (assigned to a variable, passed to another function as in the test, etc.). Printing doesn't do that - the value is simply written to the console.

That is to say the console is external to your program, not part of it.