fname = input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"

fh = open(fname)
count = 0

for x in fh:
x = x.rstrip()
wds = x.split()
if wds[0] == 'From ':
print(wds[1])
count = count + 1
else:
continue

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



https://www.edwith.org/python-data/lecture/24392/


일단 여기서 강의들으면서 하고있는데


if wds[0] == 'From ':

이 부분에서

Traceback (most recent call last):
  File "C:\Users\qqqq\Desktop\test.py", line 10, in <module>
    if wds[0] == 'From ':
IndexError: list index out of range


이런 에러가 자꾸 뜸...


내가 하려는건 메일주소가 포함된 문서파일에서 메일주소 뽑아내는거거든?


근데 왜 에러나는거임 ㅠㅠ 도와죠