ivantanchev

Problem 2 - Destination Mapper

Jul 28th, 2022
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. import re
  2.  
  3. text = input()
  4. pattern = r'\=[A-Z][A-z]{2,}\=|\/[A-Z][A-z]{2,}\/'
  5. matches = re.findall(pattern, text)
  6. power = 0
  7. result = []
  8. places = ""
  9. for place in matches:
  10.     places += place
  11. pattern_two = r'[A-z]+'
  12. result = re.findall(pattern_two, places)
  13. for dest in result:
  14.     power += len(dest)
  15. print(f'Destinations: {", ".join(result)}')
  16. print(f"Travel Points: {power}")
Advertisement
Add Comment
Please, Sign In to add comment