# Removes (Pops) the last 6 items from a list
del myList[-6:]
# Removes the second item from a list (index starts at 0)
myList.pop(1)
# Slices the list and keeps only the first 6 items
myList = myList[:6]
item_list = ['item', 5, 'foo', 3.14, True]
list_to_remove = ['item', 5, 'foo']
final_list = list(set(item_list) - set(list_to_remove))
# Python program to remove empty tuples from a
# list of tuples function to remove empty tuples
# using list comprehension
def Remove(tuples):
tuples = [t for t in tuples if t]
return tuples
# Driver Code
tuples = [(), ('ram','15','8'), (), ('laxman', 'sita'),
('krishna', 'akbar', '45'), ('',''),()]
print(Remove(tuples))
mylist=['a','b','c','d','e','f','g','h','i']
newlist = mylist[2:-2]