我已经开始学习python,我需要一些帮助。任何事情都会有帮助
我用:
科莫多编辑<-编写python
终端(我的编辑器)<-错误测试
def score():
question_1 = "null" #var
question_2 = "null" #var
q_1_answer = 0 #var
q_2_answer = 0 #var
while 1:
try:
question_1 = raw_input("do you like green eggs and ham? str((y/n))") # avoid malicious input
except (y or n ): # but this input
q_1_answer = 1 # do this
break # stop the while loop
while 1:
try:
question_2 = raw_input("do you like yellow eggs and spam? str((y/n))")
except (y or n ):
q_2_answer = 1
break
# I respond to input
if question_1 == y:
print "green eggs str(0_o")\""
elif question_1 == n:
print "yay 1"
else:
print "error, you beat my code! Well done!"
# I respond to input
if question_2 == y:
print "yellow eggs str(0_o")\""
elif question_2 == n:
print "yay 2"
else:
print "error, you beat my code! not well done! shame!!!!!!!!"
# answer total question: my input
if q_2_answer + q_1_answer > 2:
return "oi you did well. thanks!!!!"
elif q_2_answer + q_1_answer > 1:
return "you only answered one question?"
else
print "not funny" `