Stop using parallel lists. Start using dictionaries.


Timothy was hunched over his desk, his finger tracing a line across his screen. He looked like he was trying to solve a word search puzzle.

"Found it," he muttered, typing a number. Then he scrolled back up, traced another line, and typing again.

Margaret watched him for a moment. "You look like a man searching for a needle in a stack of needles."

"I’m building a phone directory," Timothy said, not looking up. "I have a list of customer names and a list of their ID numbers. When I need to find a customer’s ID, I have to find their position in the names list, and then grab the item at the same position in the ids list."

He showed her his code.

# Timothy's "Parallel List" Strategy
names = ["Alice",...

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help