Error with output from a variable....

Peter Jensen peterj at mail.com
Mon Sep 20 20:22:44 EDT 2004


Hi all.

I been playing around with this program, that lets you enter a student name, 
his studentcard numner and his address. You can then change the data, save 
it as a file, and load it again. All works except one tiny thing.

The error is in the: def udskriv_stud(studs):

def udskriv_stud(studs):
    print "De studerende i gruppen er:"
    for x in studs.keys():
        print "Navn: ",x," \tAarskortnummer: ", studs[x], "\tAdresse:" 
,adresse, #<--- Here is the error
        print ""
    print

When I enter more than one student the new address will overwrite the old 
one. So that when I print all the students in the file out, they will all 
have the address that I entered for the last student.

The code where I use the def udskriv_stud(studs): is

elif menu_choice == 2:
        print "Indtast navn og aarskortnummer:"
        navn = raw_input("Navn:")
        aarskortnummer = raw_input("Aarskortnummer:")
        adresse = raw_input("Adresse:")
        tilfoej_stud(phone_list,navn,aarskortnummer,adresse)


I can see that the it just replaces the raw_input value from adresse over 
and over again.
Do any of you have some good suggestions.

Thanks






More information about the Python-list mailing list