Remember this problem from yesterday? Take a look at the line before the one you are getting the error on. And count the ('s and the )'s.
--Todd On Sunday 31 July 2005 07:38 pm, Nathan Pinno wrote: > What the invalid syntax? Here is the error message: > SyntaxError: invalid syntax > File "D:/Python22/grades.py", line 66 > which = which-1 > ^ > SyntaxError: invalid syntax > > Here is the code: > > max_points = [25,25,50,25,100] > assignments = ['hw ch 1','hw ch 2','quiz ','hw ch 3','test'] > students = {'#Max':max_points} > > def print_menu(): > print "1. Add student" > print "2. Remove student" > print "3. Print grades" > print "4. Record grade" > print "9. Exit" > > def print_all_grades(): > print '\t', > for i in range(len(assignments)): > print assignments[1],'\t', > print > keys = students.keys() > keys.sort() > for x in keys: > print x,'\t', > grades = students[x] > print_grades(grades) > > def print_grades(grades): > for i in range(len(grades)): > print grades[i],'\t\t', > print > > def choice(): > return int(raw_input("Menu Choice: ")) > > def school(): > return raw_input("Student: ") > > while 1: > print_menu() > menu_choice = choice() > if menu_choice == 1: > print "Add student" > name = school() > students[name] = [0]*len(max_points) > elif menu_choice == 2: > print "Remove student" > name = school() > if students.has_key(name): > del students[name] > else: > print "Student: ",name," not found." > elif menu_choice == 3: > print_all_grades() > > elif menu_choice == 4: > print "Record Grade" > name = school() > if students.has_key(name): > grades = students[name] > print "Type in the number of the grade to record" > print "Type in a 0 (zero) to exit" > for i in range(len(assignments)): > print i+1,' ',assignments[i],'\t', > print > print_grades(grades) > which = 1234 > while which != -1: > which = int(raw_input("Change which Grade: ") > which = which-1 > if 0 <= which < len(grades): > grade = int(raw_input("Grade: ") > grades[which] = grade > elif which != -1: > print "Invalid Grade Number" > else: > print "Student not found" > elif menu_choice == 9: > break > else: > print "That's not a choice!" > print "Goodbye." > > Thanks for the help in advance! > Nathan
--- Begin Message ---
Here's the message:File "D:\Python22\prog4.py", line 19
while option != 9:
^
SyntaxError: invalid syntaxAnd the code:#This program finds the area and perimeter of circles, rectangles, and squares.
def menu():
print '1) Area (Circle)'
print '2) Area (Rectangle)'
print '3) Area (Square)'
print '4) Perimeter (Circle)'
print '5) Perimeter (Square)'
print '6) Perimeter (Rectangle)'
print '9) Exit'import math
print 'By Nathan Pinno'
print 'ID# 2413448'
print 'Program 4 - Functions'
menu()
option = int(raw_input('Option (1,2,3,4,5,6,9): ')
while option != 9:
if option == 1:
r = int(raw_input('Radius: ')
print 'The area of the circle = ',pi*(r**2)
option = int(raw_input('Option (1,2,3,4,5,6,9): ')
elif option == 2:
l = int(raw_input('Length: ')
w = int(raw_input('Width: ')
print 'The area of the rectangle = ',l*w
option = int(raw_input('Option (1,2,3,4,5,6,9): ')
elif option == 3:
s = int(raw_input('Side: ')
print 'The area of a square = ',s**2
option = int(raw_input('Option (1,2,3,4,5,6,9): ')
elif option == 4:
d = int(raw_input('Diameter: ')
print 'The perimeter of the circle = ',pi*d
option = int(raw_input('Option (1,2,3,4,5,6,9): ')
elif option == 5:
l = int(raw_input('Length: ')
w = int(raw_input('Width: ')
print 'The perimeter of the rectangle = ',(2*l)+(2*w)
option = int(raw_input('Option (1,2,3,4,5,6,9): ')
elif option == 6:
s = int(raw_input('Side: ')
print 'The perimeter of a square = ',s*4
option = int(raw_input('Option (1,2,3,4,5,6,9): ')
else:
print 'That is not an option. Please choose an option.'
option = int(raw_input('Option (1,2,3,4,5,6,9): ')
print 'Goodbye.'_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
--- End Message ---
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor