Skip to content

Instantly share code, notes, and snippets.

@aminnairi
Created January 12, 2021 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aminnairi/9eaecd5356e7fae0c9a128a85e7f2f05 to your computer and use it in GitHub Desktop.
Save aminnairi/9eaecd5356e7fae0c9a128a85e7f2f05 to your computer and use it in GitHub Desktop.
Challenge: write a function difference that compute the difference between
def difference(first, second):
intersection = []
for item in first:
if not item in second:
intersection.append(item)
for item in second:
if not item in first:
intersection.append(item)
return intersection
def difference2(first, second):
return [*[item for item in first if item not in second], *[item for item in second if item not in first]]
def foobar(limit):
for number in range(0, limit):
if number % 3 == 0 and number % 5 == 0:
print(f"{number}: foobar")
elif number % 3 == 0:
print(f"{number}: foo")
elif number % 5 == 0:
print(f"{number}: bar")
else:
print(number)
foobar(30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment