Skip to content

Instantly share code, notes, and snippets.

  • Save T-Bharath/eae33c117baae1d9eb3a8bdb10d60288 to your computer and use it in GitHub Desktop.
Save T-Bharath/eae33c117baae1d9eb3a8bdb10d60288 to your computer and use it in GitHub Desktop.
@JohnSha0
Copy link

fname = input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"
file = open(fname)
count = 0
for line in file:
if line.startswith("From"):
piece = line.strip().split()
print(piece[1])

print("There were", count, "lines in the file with From as the first word")

I typed this code but it repeats the the mail id if there's multiple. how can i prevent that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment