Ace school

with brainly

  • Get help from millions of students
  • Learn from experts with step-by-step explanations
  • Level-up by helping others

A community for students.

Hello, I'm attempting the homework assignment 2.8 and I'm getting a syntax error for clist.append(clname). I've declared clist as a variable in main and I cannot figure out why I'm getting this error. Anyone have an idea?

MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SIGN UP FOR FREE
I know its probably riddled with errors, but here's the code anyways. Python is giving me a syntax error on the clist in the for loop. def report_card(): clist = [] classgrade = [] classes = input("How many classes did you take? ") for num in range(0,classes): clname = raw_input("What was the name of this class? " clist.append(clname) clgrd = input("What was your grade?") classgrade.append(clgrd) n+=1
1] Sometimes it the source of the syntax errors isn't where IDLE says it is, you're missing a bracket, probably a typo: clname = raw_input("What was the name of this class? " <-- 2] It might be different for your setup, but raw_input() isn't defined for me, did you mean input()? 3] n isn't declared before you start adding it it at n+=1. You need to say what n is before the loop. 4] Finally, 'classes' will be a string. If I type '3', input() will return the string '3', not the int 3, so you need use int(classes) 5] I haven't got the assignment, but you aren't doing anything after you fill out your lists, do you mean to return something?
Thank you for the advice!! I can't believe that I missed that. I didn't include all of the code because it was giving me the syntax error in the for loop. Also, thanks for the advice on 'classes', that will help save a lot of pain in the end.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Not the answer you are looking for?

Search for more explanations.

Ask your own question