Name the license family

Dependency lists show licenses by their short SPDX names. Sort each name into its family.

What to build

A program that prints the family of every license identifier it reads.

Requirements

  • MIT, BSD-3-Clause and Apache-2.0 are permissive.
  • GPL-3.0, LGPL-3.0 and AGPL-3.0 are copyleft.
  • Anything else is unknown.
  • Print ID: FAMILY for each identifier, in the input order.

Input

The first line has n (1 to 50). Each of the next n lines is a license identifier.

Output

n lines, like MIT: permissive.

Constraints

1 ≤ n ≤ 50. Matching is case-sensitive.

Example

Input:

3
MIT
GPL-3.0
Apache-2.0

Output:

MIT: permissive
GPL-3.0: copyleft
Apache-2.0: permissive

Why it works

The three families are fixed lists, so a membership test per identifier decides the family; anything not on either list falls through to unknown, which is the safe default.

Examples

Example 1 · Input
3
MIT
GPL-3.0
Apache-2.0
Expected output
MIT: permissive
GPL-3.0: copyleft
Apache-2.0: permissive
Example 2 · Input
2
BSD-3-Clause
NONE
Expected output
BSD-3-Clause: permissive
NONE: unknown

Prompts inside input() are ignored when checking, so input("n: ") is fine.

Hints

Hint 1

Put the identifiers of each family in a set or a list.

Hint 2

Compare the whole identifier, because names are case-sensitive.

Hint 3

Print one line for each input line, in the same order.

Solution

Show one correct solution (try it yourself first)
PERMISSIVE = ["MIT", "BSD-3-Clause", "Apache-2.0"]
COPYLEFT = ["GPL-3.0", "LGPL-3.0", "AGPL-3.0"]
n = int(input())
for _ in range(n):
    name = input().strip()
    if name in PERMISSIVE:
        family = "permissive"
    elif name in COPYLEFT:
        family = "copyleft"
    else:
        family = "unknown"
    print(f"{name}: {family}")

▶ Open this solution in the compiler, then press Visualize to watch it run step by step

Lesson: Open-source licenses →