fname = input('Enter fline name: ')
if len(fname) < 1 : fname = 'mbox-short.txt'
fh = open(fname)
count = 0
for line in fh :
if 'From ' in line :
mail = line.split()
print(mail[1])
count = count + 1
else : continue
print('There were', count, 'lines in the file with From as the first word')
This is the code I saw while studying. I'm not sure how Len's presence or absence affects this code. There was no change even if I printed it out after annotating it... Why does it exist? Please give me some advice
python len
This line is
Write "mbox-short.txt"
as the default input if the input length is 0 or less (= if there is no input value).
I think it's a line that goes in that sense.
Comment on the line, rename the mbox-short.txt
file, and try again without any input. open(fname)
will probably pop.
© 2024 OneMinuteCode. All rights reserved.