Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Exercism with Python
#1
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
Reply
#2
so what does your code look like?
Please post.
Reply
#3
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)
Yoriz write Mar-15-2022, 06:17 AM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#4
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!
Reply
#5
Hello

I got the message on the screenshot,
kindly check it

thank you
Yoriz write Mar-17-2022, 06:25 AM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Attached Files

Thumbnail(s)
   
Reply
#6
What does the test says it expects your function to return, compared to what you have actually returned?
Reply
#7
Do you understand the difference between printing and returning?
Reply
#8
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?
Reply
#9
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Tracking leap.py years for gregorian calendar (Exercism org) Drone4four 11 3,658 Oct-14-2022, 03:20 PM
Last Post: betinajessen
  Meltdown Mitigation (operators + conditionals) beware: Exercism potential spoiler Drone4four 5 2,580 Feb-21-2022, 08:49 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020