Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def chunks(l, n):
- """Yield successive n-sized chunks from l."""
- for i in xrange(0, len(l), n):
- yield l[i:i+n]
- def longest_stay(fpath):
- """ Return info about the tourist with the longest stay
- :param fpath: string, path to a datafile
- :return: name(string) - the name of the tourist
- number_of_nights (int) the length of the stay
- """
- file = open(fpath)
- list_of_guests = file.read().split()
- list_of_length = []
- for entry in chunks(list_of_guests, 3):
- temp = ConvertDateToDaysSince2016(entry[2]) - ConvertDateToDaysSince2016(entry[1])
- list_of_length.append(temp)
- print(list_of_length)
Advertisement
Add Comment
Please, Sign In to add comment