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-ClauseandApache-2.0arepermissive.GPL-3.0,LGPL-3.0andAGPL-3.0arecopyleft.- Anything else is
unknown. - Print
ID: FAMILYfor 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
3 MIT GPL-3.0 Apache-2.0
MIT: permissive GPL-3.0: copyleft Apache-2.0: permissive
2 BSD-3-Clause NONE
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