Task - The Delivery MAN - Python List
{% raw %}
- Create a list of five delivery items and print the third item in the list. eg: [“Notebook”, “Pencil”, “Eraser”, “Ruler”, “Marker”]
- A new delivery item “Glue Stick” needs to be added to the list. Add it to the end of the list and print the updated list.
- Insert “Highlighter” between the second and third items and print the updated list.
- One delivery was canceled. Remove “Ruler” from the list and print the updated list.
- The delivery man needs to deliver only the first three items. Print a sublist containing only these items.
- The delivery man has finished his deliveries. Convert all item names to uppercase using a list comprehension and print the new list.
- Check if “Marker” is still in the list and print a message indicating whether it is found.
- Print the number of delivery items in the list.
- Sort the list of items in alphabetical order and print the sorted list.
- The delivery man decides to reverse the order of his deliveries. Reverse the list and print it.
- Create a list where each item is a list containing a delivery item and its delivery time. Print the first item and its time.
- Count how many times “Ruler” appears in the list and print the count.
- Find the index of “Pencil” in the list and print it.
- Extend the list
itemswith another list of new delivery items and print the updated list. - Clear the list of all delivery items and print the list.
- Create a list with the item “Notebook” repeated three times and print the list.
- Using a nested list comprehension, create a list of lists where each sublist contains an item and its length, then print the new list.
- Filter the list to include only items that contain the letter “e” and print the filtered list.
- Remove duplicate items from the list and print the list of unique items.
{% endraw %}
This post is licensed under CC BY 4.0 by the author.