Answer to Question #279941 in Python for kika

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.


1
Expert's answer
2021-12-20T10:00:10-0500
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS