Duplicate Ticket Detector
Python
25 pts
Duplicate Ticket Detector
A bus company in Asmara wants to know if any ticket number was sold twice.
- Create
unique_count— the number of different ticket numbers. - Create
has_duplicates—Trueif the list contains any repeated number. Compareunique_countwith the length of the list; do not just typeTrue. - Create
seen— an empty set. - Print
unique_count,has_duplicatesand the type ofseen.
Expected output:
4 True <class 'set'>
Checklist
- Keep
ticketsunchanged and createunique_count, the number of different ticket numbers. - Create
has_duplicatesby comparingunique_countwith the length of the list. - Create
seen, an empty set. - Print
unique_count,has_duplicatesand the type ofseen.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
