I'm learning based on Python 2! (I don't know why I'm learning it the old way.)The code I made for this problem is as below, but I don't know what's wrongPlease give strength to Python beginners!
Use random to get a random score.
import random
scores = (random.randint(1, 100) for _ in range(10))
def getAverage(values):
def sumAverage(scores): return float(scores[0]) + sumAverage(scores[1:]) if scores else 0
return sumAverage(values) / len(values) if len(values) > 0 else None
print(getAverage(sorted(scores)[1:]))
© 2024 OneMinuteCode. All rights reserved.