Exercise 14: Slices

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:

Study drill

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.

Previous
Next

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">