Abbreviating airport names.
★☆☆When boarding passes are created for passengers, the departure and arrival airport names are written in an abbreviated form to ensure they fit within the designated area on the ticket.
Write a program that allows the user to enter the names of two airports. The program should output the first four characters of each airport separated with a hypen symbol: “-“.
Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.
airports that:departure and arrival and returns the first four characters of each airport in upper case separated with a hyphen.As this is a function within a bigger system, the airport names are not input by the user. For testing purposes they are hard-coded into the function call instead. There is nothing for you to do here.
If the departure airport is London and the destination is Madrid, the output would be: LOND-MADR
If the departure airport is Palma and the destination is Manchester, the output would be: PALM-MANC
# Airline ticket program
# -------------------------
# Subprograms
# -------------------------
# Function to return truncated airport names
---
def airports(departure, arrival):
---
# Extract first four characters
---
departure = departure[0:4]
arrival = arrival[0:4]
---
# Insert dash
---
output = departure + "-" + arrival
---
# Convert to uppercase
---
output = output.upper()
---
return output
---
# -------------------------
# Main program
# -------------------------
print(airports("Gatwick", "Amsterdam"))