2

Hey DevRant Fam!, hope everyone is very well,I just started using exercism with python inside my chosen editor Emacs, and well... the first problem i'm doing is the Hello World problem...

So the code i have is here:

def hello(name='world!'):
return "Hello, {0}".format(name)
hello()

and it prints out the output "Hello,World!"
but i'm getting a strange error in my command prompt saying something like this '1 Failed Assertion error None != 'Hello, World!'
anyone have some advice its my first time working with Exercism :-) cheers!

Thank you :-)

Comments
  • 1
    What is in the test suite?
  • 0
    @No3x I haven't submitted it yet, where can i find the test suite mate?
  • 0
    @No3x ohh.. i've run it, it says this in a red highlight AssertionError: None != 'Hello, World!'
  • 2
    I don't know python well, neither exorcisms. But usually you write test cases (in code) against your test subject. Since this code is missing it's not obvious why the test fails.
  • 1
    Exorcisms is like a learning platform? Then please tell us the specification for the task. Probably you are missing a case and that's why the test fails.
  • 0
    @No3x Hello my friend, i'm sorry i could not respond quickly, however the task is as follows: The objectives are simple:

    1)Write a function that returns the string "Hello, World!".

    2)Run the test suite and make sure that it succeeds.

    3)Submit your solution and check it at the website.

    Yep! a learning platform
  • 0
    @No3x O m g i fixed it!!! i'm so happy!, you know i've been actually trying to fix this problem since like 6PM its now 8:51PM, though it may be embarrassing since its a hello world problem.. however first time using Exercism!
  • 1
    I think you are missing a return (returned value by the function is None).. and world is lower case in your code.
  • 0
    @No3x interesting!, i just ran it on my command line and it says passed :-)
  • 1
    I guess you tested an old version of your code without return by mistake. You can always check if you are testing the code you are intending to test by making a change in the code that produces some expected change in the output (e.g. introducing a syntax error).
  • 0
    @No3x to be completely honest i feel as if i may have been working with the completely wrong or separate file, i feel that the issue was that the test file 'hello_world_test.py' was actually picking up the original whilst i may have been making changes to another file, hope this makes sense and i appreciate the support along the way my friend :-)
  • 2
    Just a small improvement suggestion: You can replace format() with f-strings to make your code a bit more readable:

    return f"Hello, {name}"

    Good luck with your exercises!
  • 1
    @VaderNT Thank you my friend :-), i did not know that! cheers
Add Comment