QuestionQ179

VerifiedData Collections – Tuples, Dictionaries, Lists, and Strings

You are developing a Python application for your company.

A list named employees contains 200 employee names, with the final five being company management. You need to slice the list to display every employee except management.

Which code segments can you use?

Choose two
Explanation

Python slice index -5 denotes the position five elements before the end of the list. Omitting the start index or specifying 0 starts at the first employee, so both forms return all entries except the last five.

Community Discussion

No comments yet. Be the first to start the discussion!