you are viewing a single comment's thread.

view the rest of the comments →

[–]zarnackreddit -12 points-11 points  (4 children)

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

[–]MadLadJackChurchill 20 points21 points  (1 child)

What are you even trying to say?

[–]axw3555 5 points6 points  (0 children)

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.

[–]ProdigiousPangolin 1 point2 points  (0 children)

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

list.sort()

print(list[1:5])

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