Skip to content


Related course:


A slice can be taken from a string or list, just as you can take a slice from a pizza.
Python starts numbering of string and list elements from zero.

Slice Example:

persons = [ "John", "Marissa", "Pete", "Dayton" ]

slice = persons[0:2]

What you see on success

The program above should show a slice of the list persons.


Try the exercises below

1. Take a slice of the list below:
   pizzas = ["Hawai","Pepperoni","Fromaggi","Napolitana","Diavoli"]

2. Given the text "Hello World", take the slice "World"

After completing these continue with the next exercise.


Nested loops
Multiple return
Published inUncategorized

Be First to Comment

    Leave a Reply