IndentationError Question

Asked 2 years ago, Updated 2 years ago, 94 views

The following code was written to solve the Montyhole problem with Python.

for _ in range(trial):
    Gift = random.randomint (0, 2)
    player_choice = random.randint(0, 2)

    Fail = []

    for i in range(3):
        If i!= player_choice and i!= Gift:
            blank.append(door[i])

Here

ifi!= player_choice and i!= gift:

This line appears as IndentationError: unindent does not match any outer indication level. I think I wrote it well. Why is that?

python indentation errorcode

2022-09-20 16:32

1 Answers

Python is different from other languages Not brackets ({}) Use colons (:) and intent,
So if the indentation is not constant, the above error will occur


2022-09-20 16:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.