Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # P2PU - Python Programming 101 - Chapter 9 - Working with Files
- # Python for Informatics - Chapter 7 - Files
- # Exercise 7.3
- print '\n# Exercise 7.3\n'
- fname = raw_input('Enter a file name: ')
- if fname == 'na na boo boo':
- print '*****************************************************'
- print "*** NA NA BOO BOO TO YOU - You have been punk'd ***"
- print '*****************************************************'
- exit()
- try:
- ffile = open(fname)
- except:
- print 'File', fname, 'cannot be opened!'
- exit()
- count = 0
- for line in ffile:
- if line.find('Subject:') != -1:
- count += 1
- print 'There were %d subject lines in %s' % (count, fname)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement