Back to articles
Task 3: Delivery Man Task
How-To

Task 3: Delivery Man Task

via Dev.toJAYA SRI J

1.Create a list and print the third item Concept: Lists store multiple values. Index starts from 0. items = [ " Notebook " , " Pencil " , " Eraser " , " Ruler " , " Marker " ] print ( items [ 2 ]) Explanation: Index 2 refers to the third element → "Eraser". Add “Glue Stick” to the list Concept: Use append() to add at the end. items . append ( " Glue Stick " ) print ( items ) Explanation: append() adds a new item to the end of the list. Insert “Highlighter” Concept: Use insert(index, value). items . insert ( 2 , " Highlighter " ) print ( items ) Explanation: “Highlighter” is inserted at index 2 (between 2nd and 3rd items). Remove “Ruler” Concept: Use remove(). items . remove ( " Ruler " ) print ( items ) Explanation: Removes the specified value from the list. 5.Print first three items Concept: List slicing. print ( items [: 3 ]) Explanation: [:3] returns first three elements. Convert to uppercase Concept: List comprehension. upper_items = [ item . upper () for item in items ] print ( up

Continue reading on Dev.to

Opens in a new tab

Read Full Article
3 views

Related Articles