18
I was writing the same code over and over for a week before I learned about functions
I was making a simple number guessing game in Python and kept copying my 'check the guess' logic every single time the player took a turn. After about seven copies, my friend looked at my screen and just said, 'You know you can make a function for that, right?' I felt so dumb. I rewrote it with one function and my code went from 50 messy lines to about 20 clean ones. Has anyone else had a basic concept like that just click way later than it should have?
3 comments
Log in to join the discussion
Log In3 Comments
wyattc762mo ago
Dude that exact thing happened to me with arrays. I was making a to-do list app and had like 12 separate variables for tasks before a buddy was like "bro, use an array." I felt like such a caveman.
6
the_rowan3mo ago
Welcome to the club, we meet on Tuesdays. I did the same thing with a bunch of print statements before realizing I could just loop them. The real fun starts when you figure out you can put functions inside other functions and your brain melts all over again.
5
jason5243mo ago
Used to think functions were just extra work. Now I can't imagine coding without them.
4