list #1.py - # method for list ' 1. list_example.append(x)...

This preview shows page 1 - 2 out of 2 pages.

# method for list'''1. list_example.append(x) # add x into the end of list_example2. list_example.extend([a,b,c] # add list [a,b,c] into the end of list_example3. list_example.insert(a,x) # add x to list_example[a]4. list_example.remove(n) # remove n (p.s n can be int or char or float) fromlist_example5. list_example.pop() #delete the last element of list_example and print it6. del list_example[m:n] # delete the elements bewteen the m and n fromlist_example'''a = 1while a:list1 = []for i in range(10):print('I am going to use append')list1.append(i+1)print('Here come with result:',list1)if len(list1) == 10:print('I already add 1-10 in to list1')breakprint('Now, it is time for remove')for i in range(10):if len(list1) == 10:list1.remove(2)print(list1)elif len(list1) == 9:list1.remove(4)print(list1)elif len(list1) == 8:
End of preview. Want to read all 2 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
N/A
Tags
The Elements, end of list, last element of list

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture