Functions Review


#1

What am I doing wrong? This is from 17.Review: Functions:

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

When I run it in Codeacademy I don’t get any output in the console


#2

Be sure that your text phrases match the instructions exactly. We cannot tell if there are any indentation errors since you haven’t formatted your post.

Please remember to include a link to the exercise and any error messages. Thanks.


#3

@mtf Thank you Roy. I am new in CodeAcademy Community Forums. I have just familiarized myself with how to format my code when posting. Does it look better now?


#4

Yes, since it helps us examine that aspect, as well. Python depends upon indentation to determine block scope.

Did you check your strings? Can we have a link to the exercise so we can check?


#5

@mtf How/where do I get a link to the exercise?


#6

Copy the URL in the location bar and paste it into a post (or the OP if you can still edit). Remember to include error messages, too. Thanks.


#7

@mtf

https://www.codecademy.com/en/courses/learn-python/lessons/functions/exercises/review-functions


#8

Because there is nothing printed. That’s what is expected. If you wish to test it, write three print statements…

print shut_down('yes')
print shut_down('no')
print shut_down('yup')

You should be able to pass the lesson without testing, but feel free to test after you pass.


#9

I guess I was mistaken in how to properly call the function. I was just trying to call it with

shut_down(string)

where I should actually be calling it with

print shut_down(string)

Sorted it out. Thanks


#10

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.