Skip to content

Commit 1ec2719

Browse files
W3HWV2
1 parent d648e99 commit 1ec2719

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

‎Week03/sequences.py‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
def remove_duplicates(a_list):
22
my_list = a_list[:]
3-
x = 1
4-
for i in my_list:
5-
for j in my_list[x:]:
6-
if i == j:
7-
my_list.remove(i)
8-
x -=1
9-
break
10-
x +=1
11-
3+
for i in a_list:
4+
x = True
5+
for j, k in enumerate(my_list):
6+
if i == k:
7+
if x:
8+
x = False
9+
else:
10+
del my_list[j]
1211
return my_list
1312
def list_counts(a_list):
1413
my_list = a_list[:]
@@ -35,6 +34,6 @@ def reverse_dict(a_dict):
3534
return my_dict
3635

3736
if __name__ == "__main__":
38-
print(remove_duplicates([1,5,4,4,4,6,41,54,54,41,6]))
37+
print(remove_duplicates([1,5,5,4,4,4,6,6,6,41,41,41,41,41,41,54,54,54,54,54,54,54,54,41,6]))
3938
print(list_counts([1,5,5,4,4,4,6,6,6,41,41,41,41,41,54,54,54,54,54,54,54,54,41,6]))
4039
print(reverse_dict(list_counts([1,5,5,4,4,4,6,6,6,41,41,41,41,41,54,54,54,54,54,54,54,54,41,6])))

0 commit comments

Comments
 (0)