-1

Write an expression that prints "Eligible" if user_age is between 18 and 25 inclusive. Ex: 17 prints "Ineligible", 18 prints "Eligible".

user_age = int(input())

if ''' Your solution goes here ''':
    print('Eligible')
else:
    print('Ineligible')

I keep putting (user_age <= 25) what am I doing wrong?

Mike Scotty
  • 10,530
  • 5
  • 38
  • 50
apoorcoder
  • 1
  • 1
  • 1
  • 1
    Not including the lower bound. – erip Oct 27 '21 at 15:01
  • ``user_age <= 25`` is also ``True`` for all ages below ``18``, even negative values. You need to extend your check to consider the upper bound (25) **and** the lower bound (18) – Mike Scotty Oct 27 '21 at 15:01
  • How would I write that? – apoorcoder Oct 27 '21 at 16:53
  • Does this answer your question? [Determine whether integer is between two other integers](https://stackoverflow.com/questions/13628791/determine-whether-integer-is-between-two-other-integers) – mkrieger1 Apr 13 '23 at 22:15

1 Answers1

0

Here is the correct code for CHALLENGE ACTIVITY 5.2.1: Detect number range.

Write an expression that prints "Eligible" if user_age is between 18 and 25 inclusive.

Ex: 17 prints "Ineligible", 18 prints "Eligible".

user_age = int(input())

if user_age >= 18 and user_age <= 25 :
    print('Eligible')
else:
    print('Ineligible')
aaossa
  • 3,763
  • 2
  • 21
  • 34
Nawid
  • 1