+ 1
Is Sololearn teaching any ways to optimize the code?
https://www.sololearn.com/en/compiler-playground/cbTmuu6hj7S7 Maybe later in the course or in a separate course? For the record, i'm pushing through the old Python Core. To me, this code somehow feels a little crude (i am a beginner, after all). Anything that can be done to streamline it? Also, the approach i used in the code can be used to pull specific elements out of one list and place them in 2, 3, n other lists, according to a specific criteria in the if statement(s), right? That is, if i'm thinking in the right direction.
1 RĂ©ponse
+ 6
Hi Igor MatiÄ,
Great that youâre thinking about improving your code! Here are some key tips:
âą Follow PEP 8 for readability.
âą Use functions to keep code modular.
âą List comprehensions and generators can simplify loops.
âą Efficient algorithms and data structures boost performance.
âą Caching helps avoid redundant calculations.
âą Read and revisit code â Studying othersâ code and refining your own is key to improving over time.
And yes, your approach of distributing elements based on conditions is a useful technique.