Modifying Lists

Practice Labs Module
Time
6 minutes
Difficulty
Intermediate

Welcome to the Modifying Lists Practice Lab. In this module, you will be provided with the instructions and devices needed to develop your hands-on skills.

Join over 3 million cybersecurity professionals advancing their career
Sign up with
or

Already have an account? Sign In »

Overview

Introduction

Welcome to the Modifying Lists Practice Lab. In this module, you will be provided with the instructions and devices needed to develop your hands-on skills.

Learning Outcomes

In this module, you will complete the following exercise:

  • Exercise 1 - Performing Basic Operations on Lists

After completing this lab, you will be able to:

  • Write a program to update an item in a list
  • Write a program to append an item to a list
  • Write a program to find the index of a list item
  • Write a program to delete an item from a list

Exam Objectives

The following exam objective is covered in this lab:

  • 1.2 Perform data and data type operations

Lab Duration

It will take approximately 15 minutes to complete this lab.

Exercise 1 - Performing Basic Operations on Lists

Lists enable you to store an ordered sequence of related items and perform the same methods and operations on multiple values at once.

Some of the basic operations possible on lists are as follows:

  • Replacing specific items: You can use indexing to change items within the list by simply setting an index number to a different value.
  • Appending items: You can add more items to a list. The append() function can be used to add more items at the end of a list.
  • Searching items: You can use the index() function to find the position of a given item in a list.
  • Removing items: Items can be removed from lists by using the del statement. This will delete the value at the index number you specify within a list.

Being able to modify items in lists gives you the ability to manage lists in an efficient way.

In this exercise, you will learn to write programs to perform all the above-mentioned basic operations on lists.

Learning Outcomes

After completing this exercise, you will be able to:

  • Write a program to update an item in a list
  • Write a program to append an item to a list
  • Write a program to find the index of a list item
  • Write a program to delete an item from a list
Learning Partner
Comprehensive Learning

See the full benefits of our immersive learning experience with interactive courses and guided career paths.