-
Notifications
You must be signed in to change notification settings - Fork 0
/
Remove_item().py
35 lines (35 loc) · 1.06 KB
/
Remove_item().py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def remove_item(item,container,multi = True):
#---------------------------------------
if type(container) == list:
if multi:
while item in container:
container.remove(item)
else:
container.remove(item)
return container
#---------------------------------------
elif type(container) == dict:
if multi:
while item in container:
del container[item]
else:
del container[item]
return container
#---------------------------------------
elif type(container) == set:
if multi:
while item in container:
container.remove(item)
else:
container.remove(item)
return container
#---------------------------------------
elif type(container) == tuple:
container = list(container)
if multi:
while item in container:
container.remove(item)
else:
container.remove(item)
container = tuple(container)
return container