I am trying to make a simple little program using Python 3.7.4. I was wondering if it is possible (If so, how?) to change the Boolean value of a variable from a user input.
As you can see in the attached code, I have tried putting the append in quotations. I also tried no quotations.
is_male = []
is_female = []
is_tall = []
is_short = []
ans_male = bool(input("Are you a male? (True or False): "))
if ans_male == "True":
is_male.append("True")
if ans_male == "False":
is_male.append("False")
ans_female = bool(input("Are you a female? (True or False): "))
if ans_female == "True":
is_female.append("True")
if ans_female == "False":
is_female.append("False")
ans_tall = bool(input("Are you tall? (True or False): "))
if ans_tall == "True":
is_tall.append("True")
if ans_tall == "False":
is_tall.append("False")
ans_short = bool(input("Are you short? (True or False): "))
if ans_short == "True":
is_short.append("True")
if ans_short == "False":
is_short.append("False")
I expect the is_male, is_tall, etc. variable's value to change to True or False according to the input.
"True"/"False" (type --> str)instead ofTrue/False (Type --> bool)