← back to unit
Medium
# power tools medium
The First Repeat, Turbo Mode
In the Searching unit you found the first repeated card with a list and a nested loop. The turbo version uses a set — same answer, way less work. 🎴⚡
You get a list of cards. Print the first card that appears a second time, or no repeats.
Example:
Input: cards = ["sun", "moon", "star", "moon", "sun"]
Output: moon
"sun", "moon", and "star" are all new the first time. The second "moon" is the first card seen a second time.
💡 need a hint?
pt-first-repeat-turbo.py🔒 given lines are locked — write your code in between
loading...