Advertisement
snow27

Ad Astra

Dec 2nd, 2020
1,476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import re
  2.  
  3. text_string = input()
  4.  
  5. regex = r'(#|\|)([A-Za-z\s]+)\1(\d{2,2}/\d{2,2}/\d{2,2})\1(\d{,5})\1'
  6. new_list = []
  7. sum_call = 0
  8. for match in re.finditer(regex, text_string):
  9.     new_list.append([match.group(2), match.group(3), match.group(4)])
  10.     sum_call += int(match.group(4))
  11. days = sum_call // 2000
  12. print(f"You have food to last you for: {days} days!")
  13. for match in new_list:
  14.     print(f"Item: {match[0]}, Best before: {match[1]}, Nutrition: {match[2]}")
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement