F
12

I was writing my own loops for everything until a guy at a meetup asked me why

For months, I was building a little weather app in Python and I kept writing these long, messy loops to do simple stuff like find the highest temperature in a list. I thought that was just how you did it. Then, at a local coding meetup in Denver last Tuesday, I showed my code to this guy named Mark. He looked at it for about ten seconds and said, 'You know Python has built-in functions for that, right?' He pointed at my screen and typed 'max(my_temps)' and it did the same thing as my 8-line loop. My mind was BLOWN. I had been making everything so much harder for myself because I didn't take the time to really learn the standard library. I spent the whole next day just reading the official docs for lists and dictionaries. Has anyone else had a moment like that, where you realized you were using a really roundabout way to solve a simple problem?
3 comments

Log in to join the discussion

Log In
3 Comments
kaigibson
kaigibson27d ago
Sounds like you and @finleyl39 were both reinventing the wheel, badly.
5
smith.parker
Been there, done that.
2
finleyl39
finleyl3927d ago
Yeah, the standard library is full of those little shortcuts. I wasted a whole week once before finding collections.Counter.
3