I am writing a function that accepts a list of scores and when the j
number is bigger than the average of all the numbers before it, at least once, it returns True
, otherwise it returns False
.
My only problem is that when I enter for example [1,1,1,9999]
it returns False False True, I want only one True without the Falses. And for example, entering [1,1,2,2,3]
returns 4 times False, I only need False once. How do I do that?
My code:
def Outstanding_Scores(scores):
for j in range(0,len(scores)-1):
if sum(scores[j::-1])//len(scores[j::-1]) < scores[j+1]:
print('True')
break
else:
print('False')
scoresInput = input().split(',')
scoreslist = [int(i) for i in scoresInput]
Outstanding_Scores(scoreslist)
EDIT: My code
def Outstanding_Scores(scores):
for j in range(0,len(scores)-1):
return True if (sum(scores[j::-1])//len(scores[j::-1]) < scores[j+1]) else False
scoresInput = input().split(',')
scoreslist = [int(i) for i in scoresInput]
suspicious_income(scoreslist)