Seite 1 von 1

Else / if

Verfasst: Mittwoch 15. November 2017, 19:17
von Reloaded
Hallo!,

Ich versuche ein kleines Text Adventure in Python zu erstellen da ich ziemlich neu bin weiß ich nicht genau was bei meiner Else / if funktion nicht stimmt.

Ich bekomme zwar keine "Error Message" aber es kommt immer wieder die gleiche Antwort raus.

Der Code ist hier https://paste.ee/p/FgFbn.

Ich habe schon If else und elif probiert. Kam aber nicht weiter.

Ich benutzte die Python Version 3.5.0

Re: Else / if

Verfasst: Mittwoch 15. November 2017, 19:24
von Sirius3
Du benutzt `chose` gar nicht. Wie soll Python wissen, dass die Eingabe `right` mit der Variable right zusammengehört?

Du mußt mit einem String vergleichen:

Code: Alles auswählen

print("Which way will you chose?")
print("The dark left way or the brigh right way?")

chose = input()

if chose == "left":
    print("In the Dark left way you found a bag of Money.")
elif chose == "right":
    print("In the brigh right way you saw an old man and said Hello but it was a Thief and Stole all your Money! xD")

Re: Else / if

Verfasst: Mittwoch 15. November 2017, 19:49
von Reloaded
Sirius3 hat geschrieben:Du benutzt `chose` gar nicht. Wie soll Python wissen, dass die Eingabe `right` mit der Variable right zusammengehört?

Du mußt mit einem String vergleichen:

Code: Alles auswählen

print("Which way will you chose?")
print("The dark left way or the brigh right way?")

chose = input()

if chose == "left":
    print("In the Dark left way you found a bag of Money.")
elif chose == "right":
    print("In the brigh right way you saw an old man and said Hello but it was a Thief and Stole all your Money! xD")
Ich Danke dir vielmals ! :)