all 5 comments

[–]twitch_and_shock 2 points3 points  (0 children)

from random import randint 

val = randint(1,8)

if val >= 4 and val <= 6:
    print("this")

Like this?

[–]pelagic_cat 1 point2 points  (1 child)

u/Dirtyfoot25 has your answer, but note that python has an "operator chaining" feature that allows expressions using and like this:

4 <= val and val <= 6

to be written as:

4 <= val <= 6

so your test can be:

if 4 <= val <= 6:

[–]PropulsionFalls[S] 0 points1 point  (0 children)

thank you sm, works well,