2021年1月23日星期六

Why is this basic if-else expression failing?

This is my first post on the site. I am in my third week of coding class and have completed everything but this problem. We are using ZyBooks. I have completed everything but this participation exercise. It isn't graded; however, it is driving me nuts. We are asked to write an expression that will print "in high school" if the value of user_grade is between 9 and 12 (inclusive).

Sample output with input: 10 in high school

This is what I have so far: I apologize if I am posting this incorrectly.

user_grade = int(input())  if user_grade >= 9 <= 12:      print('in high school')  else:      print('not in high school')  

The code passes all tests until it runs input: 13. Then I receive this error:

Output differs. See highlights below.

Special character legend Your output: in high school

Expected output: not in high school

https://stackoverflow.com/questions/65866137/why-is-this-basic-if-else-expression-failing January 24, 2021 at 08:53AM

没有评论:

发表评论