mirror of
https://github.com/Aroy-Art/Learning-Python.git
synced 2024-12-28 06:55:53 +01:00
Compare commits
No commits in common. "b1ad7643ff924ebd9fffe52cbc5b79f4834dea6a" and "92d6f446b6ba1e0298e7ab1935bc77babe2a0417" have entirely different histories.
b1ad7643ff
...
92d6f446b6
2 changed files with 1 additions and 28 deletions
|
@ -37,7 +37,7 @@ An example of how you can make explosions in pygame zero.
|
||||||
|
|
||||||
<u>**How to run:**</u>
|
<u>**How to run:**</u>
|
||||||
|
|
||||||
To run the example you need PyGame Zero. You can install it by running this command:
|
To run the example you need PyGame Zero. You can install it by runnig this command:
|
||||||
>$ pip3 install pgzero
|
>$ pip3 install pgzero
|
||||||
|
|
||||||
And to run the example run this command in the main folder:
|
And to run the example run this command in the main folder:
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
#!/bin/python3
|
|
||||||
|
|
||||||
|
|
||||||
# input string, i.e. "xx:xx:xx:xx:xx:xx,xx:xx:xx:xx:xx:xx"
|
|
||||||
macs_raw = "00:04:A5:A3:3B:B0,00:27:22:56:60:8D,00:27:22:56:68:DA,00:27:22:56:69:EC,00:27:22:56:6F:6B,00:27:22:56:6F:6B"
|
|
||||||
|
|
||||||
# split the input string of mac address with a ","
|
|
||||||
macs = macs_raw.split(",")
|
|
||||||
|
|
||||||
def list_duplicates(seq):
|
|
||||||
seen = set()
|
|
||||||
seen_add = seen.add
|
|
||||||
# adds all elements it doesn't know yet to seen and all other to seen_twice
|
|
||||||
seen_twice = set( x for x in seq if x in seen or seen_add(x) )
|
|
||||||
# turn the set into a list (as requested)
|
|
||||||
return list( seen_twice )
|
|
||||||
|
|
||||||
# get the duplicates for the list_duplicates() function
|
|
||||||
dups = list_duplicates(macs)
|
|
||||||
|
|
||||||
# Print number of duplicates
|
|
||||||
print("Found %s duplicate(s)." % (len(dups)))
|
|
||||||
|
|
||||||
# print a list of all duplicates
|
|
||||||
for i in dups:
|
|
||||||
print(i)
|
|
||||||
|
|
Loading…
Reference in a new issue