Inputting the student name from the user


#1

lloyd = {
"name": "Lloyd",
"homework": [90.0, 97.0, 75.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
}
alice = {
"name": "Alice",
"homework": [100.0, 92.0, 98.0, 100.0],
"quizzes": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0]
}
tyler = {
"name": "Tyler",
"homework": [0.0, 87.0, 75.0, 22.0],
"quizzes": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}

Add your function below!

def average(numbers):
total = sum(numbers)
#print total
new_total = float(total)
average = new_total/len(numbers)
#print average
return average

numbers = [33,22,11,44,55]

average(numbers)

Add the weighted average assignment here

def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
wt_avg = 0.1*homework + 0.3*quizzes + 0.6*tests
print wt_avg
return wt_avg

function for getting a letter grade

def get_letter_grade(score):
if score >= 90:
grade = "A"
elif score >=80:
grade = "B"
elif score >= 70:
grade = "C"
elif score >= 60:
grade = "D"
else:
grade = "F"
print grade
return grade

call the function

get_average(lloyd)

student_name = raw_input('Enter the student name:')
get_letter_grade(get_average(student_name))

Every time I run this it gives me an error saying string indices must be integers. it looks like the input I'm giving it's taking it as a string and not as a dictionary. Can someone help here?


#2

can you copy the code in preformatted so we can see your indentation? and does it say what line your error occurs on?