我正在编写一个简单的测试,应该计算用户回答“是”和“否”的次数。这里是我的代码:计数满足条件的次数(Python)
questions = ["Are you happy?", "Did you shower?", "Are you Turkish?", "Are you bored?", "Do you have friends?"]
yes = 0
no = 0
for each in questions:
answers = input(each)
if answers == "yes":
yes =+ 1
elif answers == "no":
no =+ 1
print(yes, no)
要么回答“是”或“否”的问题,回答的Python Output: (0,0)
我在做什么错后?
编辑:我得到确切的输出是在这里:
[email protected]:~/enviroments$ python quiz.py
Are you happy?yes
Did you shower?no
Are you Turkish?yes
Are you bored?no
Do you have friends?yes
(0, 0)
目前正在输出什么是指示你有什么不对? – idjaw
我的不好,我会在一秒内编辑它。它给了我'输出:(0,0)' –
你已经在两个地方写了'= +',我相信你会写'+ ='。 –