Advertisement
dvdjaco

8.3

Feb 18th, 2012
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. # #!/usr/bin/python
  2. #
  3. # By dvdjaco
  4. # Exercise 8.3
  5. #
  6. # Rewrite the guardian code in the above example without two if statements.
  7. # Instead use a compound logical expression using the and logical operator with # a single if statement.
  8. #
  9. # R: with the 'and' statement? Seems better to use 'or' (actually can't think of a use of 'and' that would accomplish the same)
  10.  
  11. fhand = open('mbox-short.txt')
  12.  
  13. for line in fhand:
  14.     words = line.split()
  15.     # print 'Debug:', words
  16.     if len(words) == 0 or words[0] != 'From' : continue
  17.     print words[2]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement