I want to only print out the line count and hashtag count only if the line starts with "RT" AND has at least 1 hashtag in it. i.e. there should be no lines of code that print out as "49 : 0"
PLEASE HELP - feel like I'm nearly there but need to add some more code into the second for loop. I'm getting confused with my indentation.
enter code here
hashtag_count = 0 enter code here
line_count = 0 enter code here
for line in open("tweets.txt"): enter code here
line_split = line.split() enter code here
hashtag_count = 0 enter code here
if line.startswith("RT "): enter code here
for word in line_split: enter code here
if "#" in word: enter code here
hashtag_count += 1 enter code here
print(str(line_count) + " : " + str(hashtag_count)) enter code here
line_count += 1
Aucun commentaire:
Enregistrer un commentaire