Function reivew


I typed this code, but it have't been worked yet. what's wrong?

def shut_down(s):
return s
if s == "yes":
return "Shutting down"

elif s == "no":
    return "Shutdown aborted"
    return "Sorry"



The reason of bug here is early introduction of return statement and probably wrong indentation.

When function reach to return statement it just halts itself and takes execution out of functions body so you need to delete that line?

Also make sure that if/elif/else blocks are indented well!
By indentation I mean proper spaces between different portion of code blocks.
We generally use 4-spaces (spacebar).


thanks :slight_smile:
the problem really solved by deleting (return s) from the code


I hope concept of return is clear!
Its important cus ahead in course we're going to meet a lot of return-based functions.


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