Skip to content

Instantly share code, notes, and snippets.



Created Nov 8, 2019
What would you like to do?
import json
def get_hashtags(filename):
fh = open(filename)
tweets = json.load(fh)
hashtags = set()
for tweet in tweets:
if tweet['date'].startswith('2019'):
for hashtag in tweet['hashtags']:
return hashtags
aoc = get_hashtags('aoc.json')
trump = get_hashtags('trump.json')
shared = aoc.intersection(trump)
print("@AOC used {} hashtags in 2019.".format(len(aoc)))
print("@realDonaldTrump used {} hashtags in 2019.".format(len(trump)))
print("They both used these hashtags {}".format(shared))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment