Learn
Lists and Functions
Printing out a list item by item in a function

This exercise will go over how to utilize every element in a list in a function. You can use the existing code to complete the exercise and see how running this operation inside a function isn’t much different from running this operation outside a function.

Don’t worry about the range function quite yet—we’ll explain it later in this section.

Instructions

1.

Define a function called print_list that has one argument called x.

Inside that function, print out each element one by one. Use the existing code as a scaffold.

Then call your function with the argument n.

Folder Icon

Take this course for free

Already have an account?