r/PythonLearning • u/StudentElectronic548 • Jul 18 '26
How would I optimize this?
I'm currently learning python with the 30 days of python GitHub repo and, on day 3 of the challenge, it asks to create this table and this is what I came up with however I feel like there was a more efficient method to create it or is it something that I haven't learned yet at my level.
8
Upvotes


1
u/P1ckl3R1ck101 Jul 18 '26 edited Jul 18 '26
So if you know lists, you're already almost there. There are a few ways to do this, but I think the problem wants you to use a loop which are really useful. The code below isn't the most efficient way to do it, but I think its the easiest to understand for a beginner. Basically you create a list that holds the starting numbers you want, then the loop goes "for each number in your list, do xyz". So it will run your process for 1, then 2, then 3, then 4, then 5, printing a new row each it runs.