mardi 28 avril 2020

How do I properly set these conditionals in Python?

I am VERY new to coding in general so this may come across as a stupid question.

Right now I am experimenting with conditional statements and trying to code a little decision based two-way path in the style of a text game, where the user is given two options and each option has a different outcome. Right now, the "if True" string is ALWAYS executed in the console, regardless of what the user types in. Why is this happening and how can I rewrite it to make the command happen correctly? Also, I thought I followed the instructions for pasting code here but it doesn't look quite right.

input ("Type 'left' if you want to go left and 'right' if you want to go right"

right = True 
left = False 

right = "right"
left = "left"

if True:
    print("You have been eaten by a monster. Game Over!") 
else:
    print("Congratulations you have made it to the castle!")
else:
    print("Error")```

Aucun commentaire:

Enregistrer un commentaire