What is a function?
Lesson 5 of 19 in Coddy's Into the Past || Complete Beginner for Python Strings course.
Python Functions
A function in python is a piece of code that can be reused at anytime
A function has 5 parts, 4 must have a one optional:
- keyword def
- name of function
- parentheses ()
- colon :
- and the stuff inside the function (optional)
Challenge
EasyLet's take a look:
def greeting():
return "hi"Now run the code that is given to you in the code editor and see for yourself
Try it yourself
def greeting():
return "hi"