warning: string literal in condition

后端 未结 4 1399
野性不改
野性不改 2021-02-05 08:49

Using the first bit of code below I receive two warning messages: warning: string literal in condition x2

if input == \"N\" || \"n\"
  #do this
else         


        
4条回答
  •  猫巷女王i
    2021-02-05 09:30

    change input == "N" || "n"

    to

    input == "N" || input == "n"
    

    You must also use else if instead of else

    The warning is saying that instead of a boolean or test, you have a string literal, ' n', which always evaluates to true.

提交回复
热议问题