gmo61520

Untitled

Feb 16th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. def chunks(l, n):
  2. """Yield successive n-sized chunks from l."""
  3. for i in xrange(0, len(l), n):
  4. yield l[i:i+n]
  5.  
  6. def longest_stay(fpath):
  7. """ Return info about the tourist with the longest stay
  8.  
  9. :param fpath: string, path to a datafile
  10. :return: name(string) - the name of the tourist
  11. number_of_nights (int) the length of the stay
  12. """
  13. file = open(fpath)
  14. list_of_guests = file.read().split()
  15. list_of_length = []
  16. for entry in chunks(list_of_guests, 3):
  17. temp = ConvertDateToDaysSince2016(entry[2]) - ConvertDateToDaysSince2016(entry[1])
  18. list_of_length.append(temp)
  19. print(list_of_length)
Advertisement
Add Comment
Please, Sign In to add comment