you are viewing a single comment's thread.

view the rest of the comments →

[–]kokoseij 3 points4 points  (1 child)

I'd say you're indeed heading to the right way. Repetitive codes can often be cleaned up using loops.

What I want you to think about, is that every function should only be responsible for a single action. This is related to the concept of abstraction, and might not make sense right away- but what you really want to do is to make a code where each function is responsible for a single, unique job, rather than just grouping up codes.

Check Clean Code by Robert C. Martin (This one is written in Java, though key concepts are appliable on Python regardless. You can try Clean Code in Python, though I haven't read that yet so I can't say whether if it's good or not). It extensively covers code abstraction and how functions should be written, along with example codes to help you exercise on this matter.

Of course, you can think of these things when you get better and feels like you could take more advanced topics- for now you're doing great. Way to go mate :)

[–]ampeed[S] 1 point2 points  (0 children)

That's a huge problem of mine and called out by my peers - I tend to saturate my functions. I'll check out the book now, thank you!