Question #279941

2. Give at least three examples that show different features of string slices. Describe the feature illustrated by each example. Invent your own examples.


Expert's answer

abc = [['a'], ['B'], ['c'], ['d']]
letters = []

count = 1

for letter in abc:
    letters.append(letter*count)
    count += 1
middle_elements = letters[1:3] # Two elements in the middle
last_element = letters[-1] # The last element
first_two = letters[0:2] # First two elements
first_of_last = letters[-1][0] # First element of the last element

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS