Advertisement
Davitkova

02. Destination Mapper

Jun 17th, 2024
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. destinations = input()
  2. valid_destinations = list()
  3.  
  4.  
  5. def extract_destinations():
  6.  
  7.     return destinations.split('=') + destinations.split('/')
  8.  
  9.  
  10. def validate_destinations(destinations_lst):
  11.  
  12.     for destination in destinations_lst:
  13.         if str(destination[:]).isalpha() \
  14.                 and str(destination[0]) == str(destination[0]).upper() \
  15.                 and len(destination) >= 3:
  16.  
  17.             valid_destinations.append(destination)
  18.  
  19.  
  20. def calculate_travel_points():
  21.  
  22.     points = 0
  23.     for destination in valid_destinations:
  24.         points += len(destination)
  25.  
  26.     return points
  27.  
  28.  
  29. extracted_destinations = extract_destinations()
  30. validate_destinations(extracted_destinations)
  31. travel_points = calculate_travel_points()
  32.  
  33. print(f"Destinations: {', '.join(valid_destinations)}")
  34. print(f"Travel Points: {travel_points}")
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement