Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Functions, Packing, and Unpacking Getting Info In and Out of Functions Functions with Arguments and Returns

Mohd Ridzuan Ramli
PLUS
Mohd Ridzuan Ramli
Courses Plus Student 1,752 Points

Getting AssertionError in challenge

Why I am getting AssertionError in this code, but the code running fine in my terminal?what is happening? does this mean that python is dependent on the running platform?

creating_functions.py
def hello_student(name):
    return print("Hello {}!".format(name.title()))

hello_student('craig')

2 Answers

Mark Sebeck
MOD
Mark Sebeck
Treehouse Moderator 37,905 Points

First off it's great you run code in your terminal and get it to work. That shows you understand the material. To pass the challenges you have to do exactly what they ask. You have to spell everything correct and can't call the function if they don't ask you to. This will pass. Notice there is no ! after the name since it does not ask for that. Also does not ask to make it a title. The key to passing the challenges is to keep it simple. Do your experiments after you pass.

def hello_student(name):
    return "Hello {}".format(name)

Also I never saw a return print like that. Not saying its not correct since you said it works. But I would do it like this

def hello_student(name):
    return "Hello {}!".format(name.title())

print(hello_student('craig'))
Mohd Ridzuan Ramli
PLUS
Mohd Ridzuan Ramli
Courses Plus Student 1,752 Points

Yes. It does give me a green checked mark after written down this simple code instead:

def hello_student(name):
    return 'Hello, ' + name