Link Search Menu Expand Document

List Processing

In this exercise we process data stored in a List, which is an important concept in many programming languages.

In a file named list_processing.py, write a function named listproc that:

  • Takes two arguments, a list of String and a boolean flag.
  • Returns a String that is the concatenation of the list values.
  • If the flag is set to True, transform each list element which has an even index value to an uppercase String.

Calling listproc(['one','two','three'], True) returns ONEtwoTHREE, for example.

Mentoring topics

Discuss the use of lists, sets, and others similar structures.

Test code

To validate your code, download the test code below and run it as explained on the Hello, Python exercise page.

Test code: list_processing_test.py