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

Recommended Answers

All 2 Replies

Generally ...

if low <= number <= high:
    # do something

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.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.