FAQ: Functions - Review: Functions


#1

This community-built FAQ covers the “Review: Functions” exercise from the lesson “Functions”.

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

Learn Python

FAQs on the exercise Review: Functions

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!

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

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

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!


#2

In exercise 17/19, I do not understand how to make this “def speak(message):” example code run without errors.

I am able to make the Instructions shutdown() code operate ok but the example code looks weird somehow ???


#3

Code work in Python 3.7.1, but in exercise 17/19 not work. Please, help.


#4

If I’m not mistaken, CodeCademy has Python 2, not 3.7.1. Most sites has a 3 at the most.

I hope this helps =)


#5

It looks to be working in the exercise environment. Perhaps it is not being accepted by the lesson checker? If not, then remove the print statements and only print the return value at the caller.


#6

I could not understand the instructions. It looks like I can run the code without using “return”

Below is the code (indentation not reflecting here) and it runs what is required. I am trying to understand the difference between print and return.

def shut_down(s):
if s == “yes”:
print (“Shutting down”)
elif s == “no”:
print (“Shutdown aborted”)
else:
print (“Sorry”)

shut_down(“yes”)

When I tried this code with return and it looks like it is going as a indefinite loop. Throwing an error - “max recursion depth exceeded.”

def shut_down(s):
if s == “yes”:
print (“Shutting down”)
return shut_down(s)
elif s == “no”:
print (“Shutdown aborted”)
return shut_down(s)
else:
print (“Sorry”)
return shut_down(s)

shut_down(“yes”)


#7

def shut_down(s):
if s == “yes”:
return “Shutting down”
elif s == “no”:
return “Shutdown aborted”
else:
return “Sorry”

hi. why cant I use =
why must it be ==


#8

hi. why cant I use =
why must it be ==


#9

= is for assignment, only. == is for comparing, as in testing for equality.