Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
my code won't run...
#1
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]
Reply
#2
Welcome!

elif 35 > compnum >= 6:
    # ....
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
Ah! that seems obvious now, thank you! Smile
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020