to my knowledge, if you input any text it will return true and if you input nothing it will return false. if it’s possible without if statements, how do i check if they inputted ‘True’ or 'False (/ ‘1’ or ‘0’) when im doing ‘bool(input("Input True or False ")’.

  • nieceandtows
    link
    fedilink
    arrow-up
    2
    arrow-down
    10
    ·
    2 years ago

    You can use eval(input). It converts string to whatever the actual content is.

    • 1rre@discuss.tchncs.de
      link
      fedilink
      arrow-up
      2
      ·
      2 years ago

      Be careful here though as it’ll run anything they type in

      There may be a way in via the parser/tokeniser which is less iffy?

      • minorninth@lemmy.world
        link
        fedilink
        arrow-up
        5
        ·
        2 years ago

        Yeah, don’t do that. Users could accidentally or maliciously type something that would get executed as python code and break your program