DEV Community

Pradeep Pep
Pradeep Pep

Posted on

TASK 4: Python Lists

1.Create a list of five delivery items and print the third item in the list. eg: [“Notebook”, “Pencil”, “Eraser”, “Ruler”, “Marker”]

Image description

2.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.

Image description

3.Insert “Highlighter” between the second and third items and print the updated list.

Image description

4.One delivery was canceled. Remove “Ruler” from the list and print the updated list.

Image description

5.The delivery man needs to deliver only the first three items. Print a sublist containing only these items.

Image description

6.The delivery man has finished his deliveries. Convert all item names to uppercase using a list comprehension and print the new list.

Image description

7.Check if “Marker” is still in the list and print a message indicating whether it is found.

Image description

8.Print the number of delivery items in the list.

Image description

9.Sort the list of items in alphabetical order and print the sorted list.

Image description

10.The delivery man decides to reverse the order of his deliveries. Reverse the list and print it.

Image description

11.Create a list where each item is a list containing a delivery item and its delivery time. Print the first item and its time.

12.Count how many times “Ruler” appears in the list and print the count.

Image description

13.Find the index of “Pencil” in the list and print it.

Image description

14.Extend the list items with another list of new delivery items and print the updated list.

Image description

15.Clear the list of all delivery items and print the list.

Image description

16.Create a list with the item “Notebook” repeated three times and print the list.

Image description

17.Using a nested list comprehension, create a list of lists where each sublist contains an item and its length, then print the new list.

Image description

18.Filter the list to include only items that contain the letter “e” and print the filtered list.

Image description

19.Remove duplicate items from the list and print the list of unique items.

Image description

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

Jetbrains image

Build Secure, Ship Fast

Discover best practices to secure CI/CD without slowing down your pipeline.

Read more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay