# Program scores3.py
# ============================================================
def is_float(s):
    """ Returns True if string is a number. """
    try:
        float(s)
        return True
    except ValueError:
        return False
# ------------------------------------------------------------
def is_int(s):
    """ Returns True if string is a number. """
    try:
        int(s)
        return True
    except ValueError:
        return False
# ------------------------------------------------------------
def getinteger(Message):
   myInteger =input(Message)
   if is_int(myInteger):
        width = int(myInteger)
   else:
        print("This was not an int.")
        print("Program Terminates in getInteger.")
        exit(-1)
   return myInteger
# ------------------------------------------------------------
def getfloat(Message):
   myFloat =input(Message)
   if is_float(myFloat):
        myFloat = float(myFloat)
   else:
        print("This was not an float.")
        print("Program Terminates in getFloat.")
        exit(-1)
   return myFloat
# ------------------------------------------------------------
def getScores(numberOfScores):
    counter = 0
    scores = []
    while(counter < numberOfScores):
        myScore = getfloat("Enter the next exam score ")
    #    print(type(myScore))
        scores.append(myScore)
        print(counter,scores)
        counter = counter + 1
    return scores
# ------------------------------------------------------------
def getScoreAverage(scores):
    sumOfScores = 0
    for dummy in scores:
        sumOfScores = sumOfScores + dummy

    averageScore = sumOfScores/len(scores)
    return averageScore
# ============================================================

# List of class members.
classList = [{'name': 'Harry', 'scores': [98, 87, 92, 96, 100]},
             {'name': 'Alice',   'scores': [89, 97, 100, 96, 100]},
             {'name': 'Mandy',   'scores': [99, 93, 100, 100, 100]},
             {'name': 'Rusty',   'scores': [99, 100, 100, 92, 100]},
             { 'scores': [99, 100, 100, 92, 100], 'name': 'Katrina', 'phoneNumber': "413-781-7822"},
             ]

for eachElement in classList:
    print(eachElement)
    print(eachElement['name'])
    print(eachElement['scores'])

averageScore = getScoreAverage(classList[0]['scores'])
print(f"Average Score for {classList[0]['name']} is {averageScore:.2f}")

for eachElement in classList:
    averageScore = getScoreAverage(eachElement['scores'])
    print(f"Average Score for {eachElement['name']} is {averageScore:.2f}")
