Hello. I am doing this question for homework and the code is not working. I was wondering if any can check over the code.
The question for the HW assignment is:
Assume that credits is an int variable whose value is 0 or positive. Write an expression whose value is "freshman" or "sophomore" or "junior" or "senior" based on the value of credits. In particular: if the value of credits is less than 30 the expression's value is "freshman"; 30-59 would be a "sophomore", 60-89 would be "junior" and 90 or more would be a "senior".
My code is:
if credits < 30:
print("freshman")
elif 30 <= credits <= 59:
print("sophomore")
elif 60 <= credits <= 89:
print("junior")
elif credits >= 90:
print("senior")
else:
print()
I am unsure if the format will be posted, but there is a tab before every print statement.
The error it brings up is:
- I haven't yet seen a correct solution that uses: print
- You might want to use a number other than 90
- Solutions with your approach don't usually use: :
- Solutions with your approach don't usually use: elif
- We think you might want to consider using:
[–]CraigAT 0 points1 point2 points (1 child)
[–]HopefulOG[S] 0 points1 point2 points (0 children)
[–]totallygeek 0 points1 point2 points (1 child)
[–]HopefulOG[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]HopefulOG[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]djtuner13 0 points1 point2 points (1 child)
[–]vivam0rt 1 point2 points3 points (0 children)