Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have started to learn python and I need some help. anything will help

I use:

komodo edit <- write the python

terminal (my editor) <- bug testing

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"    `
share|improve this question
You're looking for a debugger. – SLaks 16 hours ago
1  
What's the question? – Fls'Zen 16 hours ago
2  
404: question not found. – Jules Mazur 16 hours ago

closed as not a real question by Fls'Zen, eldarerathis, Sean Vieira, Tim, JBernardo 16 hours ago

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

These codes can run without bugs now, but you still need to refine the logics. Be careful!! Do not use the "Space Bar" to replace the "Tab".

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:
    print "oi you did well. thanks!!!!"

elif q_2_answer + q_1_answer > 1:
    print "you only answered one question?"

else:
    print "not funny"
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.