Python Forum
My If statements are being ignored
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My If statements are being ignored
#1
Okay, so basically I'm trying to make a planet generator that will spit out a few numbers based on a few specifications. the problem here is that I have an if statement asking if my temperature is above or below a certain point, and if this is true, only place a certain amount of land flora. I thought this would work fine but I am still getting outputs that shouldn't be possible when the temperature is that low. I don't know if it the "&" or what but it shouldn't be able to print out more than 30% land flora coverage if the temp is below-20 or above 40. can someone help?

from random import randint
Temp = randint(-80,80)
print(Temp)
Land = randint(0,100)

print("Land:", Land,"%")
Water=100-Land
print("Water:", Water,"%")

if Land >0 & Temp <39 & Temp > -19:
    LandFlora1 = randint(60,100)
    print("Land flora coverage:", LandFlora1,"%")
    LandLife = True
elif Land >0 & Temp >=40 or Land >0 & Temp <= -20:
    LandFlora2 = randint(0,30)
    print("Land flora coverage:", LandFlora2,"%")
    LandLife = True
else:
    print("Land life not possible")
    LandLife = False
Reply
#2
You'll need to use "and" instead of "&".
Reply
#3
(Apr-24-2020, 03:48 AM)michael1789 Wrote: You'll need to use "and" instead of "&".

Thanks, I feel... really stupid
Reply


Forum Jump:

User Panel Messages

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