Skip to lesson content
Dev4Hub

Lesson 11 of 11

Python Functions

1 min read1 sectionAI tutor ready

Defining a Function

In Python a function is defined using the def keyword.

Function with argument

Python
def my_function(fname):
    print(fname + " Refsnes")

my_function("Emil")
my_function("Tobias")
my_function("Linus")

Output

Emil Refsnes
Tobias Refsnes
Linus Refsnes

You've reached the end of this lesson.

Mark it complete to keep your place in the course — it counts toward your progress and your streak.