Python Forum

Full Version: my code won't run...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to create a system where different random numbers will display depending on the number generated.
I don't know what I've done wrong and what I need to do to fix it. Can anyone tell me what ive done wrong?

[python]
compnum = random.randint(1,40)
if compnum <6:
compnum = random.randint(8,14)
print("my number was",compnum,"\n")

elif compnum >= 6 and <35: <<this is the line that wont work(syntax error)
compnum = random.randint(14,18)
print("my number was",compnum,"\n")

elif compnum >= 35 and <41:
compnum = random.randint(18,21)
print("my number was",compnum,"\n")
[python]
Welcome!

elif 35 > compnum >= 6:
    # ....
Ah! that seems obvious now, thank you! Smile