my code won't run... - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: my code won't run... (/thread-13819.html) |
my code won't run... - ChickenWithRice - Nov-01-2018 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] RE: my code won't run... - wavic - Nov-01-2018 Welcome! elif 35 > compnum >= 6: # .... RE: my code won't run... - ChickenWithRice - Nov-01-2018 Ah! that seems obvious now, thank you! |