I have a trouble when coding

This is the place for queries that don't fit in any of the other categories.

I have a trouble when coding

Postby harrybotboy » Thu Jun 06, 2013 1:54 pm

Code: Select all
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] }

n= ["lloyd", "alice", "tyler"]

def average(n):
    return sum(n)/len(n)

a=0 for name in n:
    a += (average(name["homework"])*0.1 + average(name["quizzes"])*0.3 + average(name["tests"])*0.6) print (a/len(n))


I am just a beginner in Python programming, and when coding, I am facing a trouble. When I run my code, the compiler said name["homework"], name["quizzes"], name["tests"] is string, not are lists of numbers. Could you help me to find out any error in my code? :geek: :geek: :geek:
harrybotboy
 
Posts: 2
Joined: Thu Jun 06, 2013 1:50 pm

Re: I have a trouble when coding

Postby rrashkin » Thu Jun 06, 2013 2:43 pm

check the answer I posted on devshed.
___________________
Bob Rashkin
User avatar
rrashkin
 
Posts: 35
Joined: Tue Feb 12, 2013 4:47 pm

Re: I have a trouble when coding

Postby harrybotboy » Thu Jun 06, 2013 3:13 pm

Thank you very much, rrashkin :D
harrybotboy
 
Posts: 2
Joined: Thu Jun 06, 2013 1:50 pm


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 5 guests

cron