Issue
Complete this function to return either "Hello, [name]!" or "Hello there!" based on the input
def say_hello(name):
name = "Hello there!"
assert name != "Hello there!"
# You can print to STDOUT for debugging like you normally would
print(name)
# but you need to return the value in order to complete the challenge
return "" # TODO: return the correct value
I've tried a couple of things but run into errors such as assertion error... I have completed practice test similar to this before but I'm just drawing a blank here. Any help with the proper code and how you came to it would be greatly appreciated.
Solution
This will populate the name if one is given and it is not empty ("" evaluates to False)
def say_hello(name=None):
return f"Hello, {name}!" if name else "Hello there!"
Answered By - notoriousjere
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.