Back to problems
COMP2041
21T2 Q3 — Male surnames (Python)
Same task as Q2 but in Python: read enrolment data Course|StudentID|Name|Plan|Gender from stdin, print the surnames of male students, each once, alphabetically.
$ ./prog < enrollments.txt Carey Costner Neeson Thorpe Wang
Python only; no external programs / subprocess. From COMP2041/9044 21T2 Final.
Samples
stdin
COMP1511|3360379|Costner, Kevin Augustus |3978/1|M COMP1511|3364562|Carey, Mary |3711/1|M COMP3311|3383025|Thorpe, Ian Augustus |3978/3|M COMP4920|3860448|Steenburgen, Mary Nell |3978/3|F COMP1521|3360582|Neeson, Liam |3711/2|M COMP3411|3863711|Klum, Heidi June Anne |3978/3|F COMP3141|3383025|Thorpe, Ian Augustus |3978/3|M COMP3891|3863711|Klum, Heidi June Anne |3978/3|F COMP3331|3383025|Thorpe, Ian Augustus |3978/3|M COMP2041|3860448|Steenburgen, Mary Nell |3978/3|F COMP2041|3360582|Neeson, Liam |3711/2|M COMP3311|3711611|Klum, Mary |3978/3|F COMP3311|3371161|Thorpe, Ian Fredrick |3711/3|M COMP3331|5122456|Wang, Wei |3978/2|M COMP3331|5456732|Wang, Wei |3648/3|M COMP4920|5456732|Wang, Wei |3648/3|M
expected
Carey Costner Neeson Thorpe Wang
python3
14