Python Forum

Full Version: My If statements are being ignored
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
You'll need to use "and" instead of "&".
(Apr-24-2020, 03:48 AM)michael1789 Wrote: [ -> ]You'll need to use "and" instead of "&".

Thanks, I feel... really stupid