Python Forum

Full Version: Basic code help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey there, trying to run a basic Boolean program however I'm having trouble printing one of my options.
I want to print "True" for values equal to 0.1 or greater than 1.0 and "False" for anything in between.
The only option that won't print is the case where the value is greater than 1.0.

Here's the code:
value = 1.5

if value == 0.1:
   print("True")
elif value >0.1:
   if value <1.0:
       print("False")
else:
   print("True")
Thanks for the help!
Quote:I want to print "True" for values equal to 0.1 or greater than 1.0 and "False" for anything in between.

You are over complicating it. All you need to do is check your true values, and if not that then its false. 

value = 1.5

if value == .1 or value > 1:
    print('True')
else:
    print('False')
A simplified version of metulburr's code if you wanna be super pro...
print value == .1 or value > 1
(This is assuming that nothing funky will happen printing a boolean instead of a string, since they do both have the same string representation.)