This community-built FAQ covers the “Defining a Function” exercise from the lesson “Introduction to Functions”.
Paths and Courses
This exercise can be found in the following Codecademy content:
Visualize Data with Python
Analyze Data with Python
Analyze Financial Data with Python
Build Chatbots with Python
Build Python Web Apps with Flask
Learn Python 3
CS101 Livestream Series
FAQs on the exercise Defining a Function
There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in #get-help.
Agree with a comment or answer? Like () to up-vote the contribution!
Need broader help or resources? Head to #get-help and #community:tips-and-resources. If you are wanting feedback or inspiration for a project, check out #project.
Looking for motivation to keep learning? Join our wider discussions in #community
Learn more about how to use this guide.
Found a bug? Report it online, or post in #community:Codecademy-Bug-Reporting
Have a question about your account or billing? Reach out to our customer support team!
None of the above? Find out where to ask other questions here!
I followed all the directions but nothing is displayed on the console, what did I do wrong? I attach my code.
Your code below:
print(“Walk 4 mins to 34th St Herald Square train station”)
print(“Take the Northbound N, Q, R, or W train 1 stop”)
print(“Get off the Times Square 42nd Street stop”)
Is this your exact code? If so, the issue is most likely that the body of the function (all of the
prints, in this case) isn’t indented.
Make sure you name the function directions_to_timesSq() instead of directions_to_times_square() like I initially did. Otherwise it will not let you move on to the second step. This may seem obvious, but for whatever reason it did not register with me because my brain parsed “timesSq” as being “times_square” which the exercise didn’t like.
print(“Walk 4 mins to 34th St Herald Square train station.”)
print(“Take the Northbound N, Q, R, or W train 1 stop.”)
print(“Get off the Times Square 42nd Street stop.”)
#Call your function here:
directions_to_timesSq() this is my code but am getting this error File “travel.py”, line 1
IndentationError: unexpected indent
I have done both steps here, and even have a colen at the end of the def. But I can’t get past the first instruction and move on to the next page as it remains a “Red X” rather than a “Green checkmark”