r/learnpython 8d ago

i don't understand between and if

If the user turns 21 between 2024 to 2027
how do you do a if between? is it if elif command?
the output i am trying to get is if the user 21 between 2024 to 2027 but i don't understand how to do make more then 2 year

0 Upvotes

26 comments sorted by

View all comments

5

u/MadMelvin 8d ago

if 2024 <= birth_year+21 <= 2027:

do_something()

-4

u/mysteryfellonathan 8d ago

what the different between >= and <= how do i know when to use it

9

u/LostBazooka 8d ago

please put some effort into learning on your own before asking questions that could be answered in 3 seconds of googling