i just got into this python thing and i asked my friend how to do this and he doesnt know

he told me to write this here so you guys can understand

how to make an if statement (if x == 10 to 24) with proper syntax

8 Years
Discussion Span
Last Post by shadwickman

If you don't mind as much about memory usage, you could use

if number in range(10, 24):  # careful!
# This gives a range of 10 - 23.
# The end index (24) isn't included in it.

if number in xrange(10, 24):
# The xrange doesn't load the range list into memory all at once,
# but iterates over it one value at a time.
# This can save you a lot of memory for intensive/large-scale things.
# Again, the end index isn't included in the range.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.