[Python] User input boolean in python

Discussão em 'Python' iniciado por Stack, Agosto 18, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to have a user input whether or not they like spicy food and the output is supposed to be a boolean but I don't seem to be getting an output with my code below:

    def likes_spicyfood():
    spicyfood = bool(input("Do you like spicy food? True or False?"))
    if spicyfood == ("True"):
    print("True")
    if spicyfood == ("False"):
    print("False")
    return(likes_spicyfood)

    Continue reading...

Compartilhe esta Página