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.

Airline ticket

Make

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: “-“.

Success Criteria

Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.

Complete the subprogram called airports that:

  1. Takes the two parameters, departure and arrival and returns the first four characters of each airport in upper case separated with a hyphen.

The main program:

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.

Typical inputs and outputs from the program would be:

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
🆘 If you're really stuck, use this Parsons code sorting exercise
Complete program
# 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"))