FAQ: Introduction to Functions - Returning Values

This community-built FAQ covers the “Returning Values” exercise from the lesson “Introduction to Functions”.

Paths and Courses
This exercise can be found in the following Codecademy content:

[Beta] Learn to Code with Blockly

FAQs on the exercise Returning Values

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 (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 (reply) below!
You can also find further discussion and get answers to your questions over in Language Help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

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 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!

Hello for this example we see a coordinate grid which helps us identify the position from my understanding normally we go in the order (x,y) in this practice the correct solution was in (y,x). I was wondering is there any particular reason for that or does it not matter?

When making calls to the Get path to function, we are providing the x and y coordinates (the x coordinate is the first argument, the y coordinate is the second argument) of the target location.

After making a call to the Get path to function, when moving to the retrieve the key, Codey moves up and then right.

When moving to the door, a fresh call is made to the function and Codey moves right and then down.

So, it doesn’t seem that the function is preferring up/down motion over right/left motion or vice versa.

If this is not what you are asking about, then elaborate a bit more on your line of thinking.

When making a call to the function, we must provide the x coordinate first and the y coordinate as the second argument. The order matters.

When the function returns a path, there doesn’t seem to be a bias about which direction we move in first. We don’t really know the logic that has been implemented inside the function, so we don’t really know why Codey moves up/down first in some cases and right/left first in other cases.