[go: up one dir, main page]

0% found this document useful (0 votes)
4 views1 page

Listpy

Uploaded by

gtecstudent795
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Listpy

Uploaded by

gtecstudent795
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1. Create a list of 5 fruits and print it.

2. Access the third item from a list of numbers and print it.
3. Slice the last three elements from a list of 7 colors.
4. Append a new item to the end of a list of animals.
5. Insert an item in the second position of a list.
6. Remove an item from a list using remove().
7. Pop the last item from a list and print it.
8. Find the index of "banana" in a list of fruits.
9. Count how many times the number 3 appears in a list.
10. Sort a list of numbers in ascending order.
11. Reverse a list of strings using reverse().
12. Find the length of a list using len().
13. Extend one list with another (e.g. numbers + letters).
14. Check if a value exists in a list (e.g. "cat" in list).
15. Print all items in a list using a for loop.
16. Create a new list using list comprehension (e.g. square numbers).
17. Copy a list and show that modifying one doesn't affect the other.
18. Clear all items from a list using clear().
19. Create a nested list with 2 sublists and print an inner item.
20. Convert a string to a list of characters using list("hello").

You might also like