x = bool(input ( "Write True or False\n"))
if x is True :
print("its true")
elif x is False :
print ("its false")
when I write True or False I always get "its true". i want the program to say "its false" when i type False.
You'll have a problem with converting to bool because technically any non-empty string will evaluate to True
>>> bool('True')
True
>>> bool('False')
True
>>> bool('')
False
You can use ast.literal_eval though
>>> from ast import literal_eval
>>> literal_eval('True')
True
>>> literal_eval('False')
False
Otherwise you'll have to compare the actual strings themselves
x = input("Write True or False\n")
if x in ('True', 'true'):
print("its true")
elif x in ('False', 'false'):
print ("its false")
else:
print("don't know what that is")
elsecase.if x == "True"? In python, an empty String will be False, but any String will text in it will evaluate to True.