else:
print "Student not found"
elif menu_choice == 5:
filename = raw_input("Filename to load: ")
load_grades(students,filename)
elif menu_choice == 6:
filename = raw_input("Filename to save: ")
save_grades(s
n Pinno" <[EMAIL PROTECTED]>; "Yoo, Danny"
<[EMAIL PROTECTED]>; "Bark, Adam" <[EMAIL PROTECTED]>
Cc: "Tutor"
Sent: Tuesday, August 02, 2005 1:43 AM
Subject: Re: [Tutor] I've run into a jam on the exercise on file I/O
>
>> What if I
> What if I were to use ID's for the students and use the ID's as the
> sequence
> index, and link the students and their grades to the IDs?
Its not necessary for what you are doing but it's how you'd normally
do it
in a relational database, so if you ever needed to turn your file
based
progra
lt;[EMAIL PROTECTED]>
Cc: "Tutor"
Sent: Monday, August 01, 2005 3:03 PM
Subject: Re: [Tutor] I've run into a jam on the exercise on file I/O
>
>
> On Mon, 1 Aug 2005, Nathan Pinno wrote:
>
>> I've seem to run into a jam while working on the exercise on file
On Mon, 1 Aug 2005, Nathan Pinno wrote:
> I've seem to run into a jam while working on the exercise on file I/O.
> Here's the error:
> Filename to save: university.txt
> Traceback (most recent call last):
> File "D:\Python22\grades.py", line 99, in ?
> save_grades(students,filename)
> Fi
No sorry scratch that last one I was being stupid. The key is a string
but max_points is a list so the list index max_points[x] is effectively
looking for max_points[student].
def save_grades(students,filename):
out_file =
open(filename, "w")
for x in
students.keys():
out_file.w
Maybe I should use assignments instead?
- Original Message -
From:
Adam Bark
To: Nathan Pinno
Cc: tutor@python.org
Sent: Monday, August 01, 2005 2:47
PM
Subject: Re: [Tutor] I've run into a jam
on the exercise on file I/O
>>> max_points = [2
>>> max_points = [25,25,50,25,100]
>>> assignments = ['hw ch 1','hw ch 2','quiz ','hw ch 3','test']
>>> students = {'#Max':max_points}
>>> students
{'#Max': [25, 25, 50, 25, 100]}
The problem is the key in students is a list not an integer.On 8/1/05, Nathan Pinno <[EMAIL PROTECTED]
> wrote:
Hey all,
I've seem to run into a jam while working on the exercise on file
I/O.
Here's the error:
Filename to save: university.txtTraceback (most recent call
last): File "D:\Python22\grades.py", line 99, in
? save_grades(students,filename) File
"D:\Python22\grades.py", line 51, in save_