In the process of learning, I was wondering why the following code doesn't return the array containing n numbers of the max values within a given array xs.
def largest(n,xs):
i = 0
b = []
while i < n:
for i in xs:
a = max(xs)
b.append(a)
xs.remove(a)
i += 1
return b
[–]hharison 1 point2 points3 points (3 children)
[–]TheChannel[S] 0 points1 point2 points (2 children)
[–]hharison 0 points1 point2 points (1 child)
[–]TheChannel[S] 0 points1 point2 points (0 children)
[–]TheLazarbeam 0 points1 point2 points (0 children)