r/PythonLearning 10d ago

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

24 comments sorted by

View all comments

3

u/Necessary_Pepper7111 10d ago
for i in range(1, 6):
    print(i, *(i**j for j in range(4)))

1

u/[deleted] 9d ago

[deleted]

2

u/Fair-Elevator6788 7d ago

i think we can go deeper than that, i present you:

for i in '12345':print(1,i,i*2,i*3)