FREE INTERACTIVE ONLINE COURSE

Python 3

FOR BEGINNERS


"The first Python course that simply amazed me. Very well explained and easy to understand." (Alexandru Cosmin)

"The best Python course in Romania." (Iulian Geană)


ALL REVIEWS
LESSON 17
PAGE 3 / 4
Functions in Python (I)
Home >>> Free Online Lessons, Python 3

Displaying a List

We continue defining functions for our list by creating one that displays a list, element by element:
Editor - lesson_17.py
       
Console/Output done
DETAILS

In this case, we did not need a value or object to be returned, only to be displayed, so return is missing, being optional. We read: for each element of the object x, we display its value.

The variable list1 holds the object created by the create_list function, which is then passed as an actual parameter to the display_list function.

EXERCISE

Style the display_list function a bit. It would look better if the results were like "Element 0: a", etc.
Proceed to the next page.
 home   list  CONTENTS   perm_identity   arrow_upward