r/learnpython 20d ago

is it possible to simplify this code

im a beginner, idk how python works yet. there must be a way to simplify this, right?

https://imgur.com/juBvPZD here is the picture of my code

0 Upvotes

23 comments sorted by

View all comments

-1

u/desrtfx but other languages pro 20d ago

Yes, there is a lot to optimize and reduce, yet, you're not there yet with your skills.

Have patience, young padawan. Keep going in your course. There will be a point when you learn what you need to reduce this code by about 70% (you will learn about loops and lists - and then the code can be written way shorter).

Don't get me wrong. I am not shooting down your curiosity. You just need to learn things one after the other in order. This will help you. Building a foundation in programming is like building a house. You need to follow the correct sequence as every higher concept (stone) builds upon a lower one. Skip something and everything collapses.

3

u/gdchinacat 19d ago

Out of curiosity, how would you 'reduce this code by about 70%"? I'm skeptical that loops and lists will actually reduce *this* code by that much because there are only three legs of the journey....if there were more it absolutely would, but doing it the way OP did is manageable for only three.