Oft wenn ich Entscheidungen Strukturen (zusammen mit Raw-Eingabe) zu programmieren und zu verwenden, wird die Antwort, die ich wähle ignoriert und geht auf die erste "if" -Anweisung und zeigt die Ausgabe dafür.Python-Programmierung Entscheidung Strukturen
In der Klasse müssen wir ein Spiel mit Schleifen und Entscheidungsstrukturen erstellen. Wenn ich das Programm ausführe, stolpere ich immer wieder über das Problem, dass das Programm die Ausgabe für die 'if' Anweisung anstatt der Antwort ausgibt, die der Benutzer wählt.
Zum Beispiel;
score=0
while True:
optionOne=raw_input("Please pick one of the options!")
if (optionOne=="one" or "One" or "ONE"):
print "You have succesfully sneaked out without alerting your parents!"
print "Your current score is " + str(score)
break
elif (optionOne=="two" or "Two" or "TWO"):
print "Due to stress from work, your mom does not notice your lies and allows you to leave."
print "Your current score is " + str(score)
break
elif (optionOne=="three" or "Three" or "THREE"):
print "Your mom is understanding and allows you go to the party!"
score=score+10
print "You get 10 additional points for being honest!"
print "Your current score is " + str(score)
break
Hier wird, obwohl der Benutzer die zweite Option wählt, die Ausgabe für die erste "if" -Anweisung verwendet. Ich bin verwirrt, welche Syntaxfehler oder Fehler ich mache, damit dies geschieht.