python if statement evaluation with multiple values

后端 未结 2 1176
轻奢々
轻奢々 2021-01-23 01:14

I\'m not exactly sure why but when I execute this section of code nothing happens.

while (True) :

    choice = str(input(\"Do you want to draw a spirograph? (Y         


        
2条回答
  •  有刺的猬
    2021-01-23 01:55

    This expression doesn't do what you want:

    choice == 'n' or 'N'
    

    It is interpretted as this:

    (choice == 'n') or 'N'
    

    You might want to try this instead:

    choice in 'nN'
    

提交回复
热议问题