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 Python Basics (2015) Logic in Python Fully Functional

Sachin Kanchan
Sachin Kanchan
564 Points

Cannot execute Function call in python shell

When I make changes and save the functions.py workspace file, then the code runs fine.

But when I enter PYTHON shell, and rewrite same code, it shows error. Why? https://www.dropbox.com/s/5uwfds0ua6vpedm/python.JPG?dl=0

1 Answer

Stuart Wright
Stuart Wright
41,118 Points

To run it in the shell, you need to make sure the function definition part of your code gets executed before you can call it. To do this, press Enter a second time after your return statement so that you see the >>> prompt rather than the ...

Then enter your function call.