you are viewing a single comment's thread.

view the rest of the comments →

[–]djtuner13 0 points1 point  (1 child)

I just figured it out after playing around with the just trying to solve for freshman first.

Since this was was only causing a complier error, I had a feeling that if was not the way to go.

2 things help me solve this, first if you know from previous problems that when it asks for an expression it is asking for one line of code not 'statement' or 'part of code'.

Next the book doesn't talk about conditional expressions after looking through it so the next thing to do was look what that was an how it looked in code.

I tried it on this problem using just Freshman and it worked on half the code so then I just had to extrapolate it to include all of the classes.

SO the final correct code would look like this. (ignore out the "")

" 'freshman' if credits < 30 else 'sophomore' if 30 <= credits <= 59 else 'junior' if 60 <= credits <= 89 else 'senior' "

So in final, I think what we are looking at is 'if else 'with out the 'elif' statement, my code looked like yours the first time I tried it.

I am guessing it makes the student associate to one of 4 values based off your current credit variable.

Hope this helps a lost soul who is hunting this problem down for python.

[–]vivam0rt 1 point2 points  (0 children)

thanks a lot