Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics Functions and Looping Returning Values

Hi everybody! I wrote the code exactly like it was in the video until 4.46 and is not working for me. Please Help!

It's giving me: NameError: split_check not defined

2 Answers

Jeff Muday
Jeff Muday
Treehouse Moderator 26,933 Points

When I see an error like that it means you might have forgotten to define split_check() before you tried to use it

This can happen if you try to call to split_check() before it was defined or imported. Here I type in to the Python REPL (command interpreter) launched from the command line and you can see the error.

PS C:\Users\jeff> python
Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> # If I try to use split_check before it is defined... see error below.
>>> print(split_check(35.22, 2))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'split_check' is not defined
>>> # now, I type the function in to define it... 
>>> def split_check(total, number_of_people):
...     cost_per_person = total / number_of_people
...     return cost_per_person
>>> # now, it will work.
>>> print(split_check(35.22, 2))

Thank you very much Jeff that was really helpful!