r/learnpython • • Dec 03 '20

Python Projects for Beginners

Any sites or books for doing projects for python beginners?

372 Upvotes

76 comments sorted by

View all comments

Show parent comments

-11

u/zarnackreddit Dec 03 '20

just a beginner question is if you make an array pull the biggest 4 numbers out of it and add the four numbers and should print the four numbers and the sum of them

my high score is 3 lines for that

21

u/MadLadJackChurchill Dec 03 '20

What are you even trying to say?

5

u/axw3555 Dec 03 '20

I think it’s a challenge.

Make an array of numbers. Pull the four biggest. Sum them. Then print the numbers and the total.

And see how few lines of code you need to do it.

Doesn’t seem like a beginner challenge. Beginner challenges are “make something that does X” not “see how much you can optimise your code to make it short”. Learn to do, then learn to optimise.

2

u/ProdigiousPangolin Dec 03 '20

list=[1, 3, 50, 6, 20, 30]

list.sort()

print(list[1:5])

print(list[1]+list[2]+list[3]+list[4])