0

For a learning project, I try to write a program that asks for a name, and then display "Access granted" if and only if the name is "Thomas".

So far, I wrote this.

name = str(input("What is your name?"))

if name == "Thomas":
print("Access granted")

I would expect it to work as described earlier, but instead I get this error message :

IndentationError: expected an indented block

What does this message mean and how to fix it ? I don't know where to start.

3
  • "it doesn't work" doesn't help anyone to help you. The snippet you have isn't valid Python (if should be lower-case, print() should be indented) and Name and name are different identifiers. Commented Nov 21, 2021 at 20:45
  • It doesn't work because Name is not the same as name (case-sensitivity), If doesn't exist in the language, it would be if and you didn't indent it correctly Commented Nov 21, 2021 at 20:46
  • Hey, I edited your question to format it in a way that makes it easier to understand what you are trying to achieve and answer. Commented Nov 21, 2021 at 20:56

1 Answer 1

2

In Python the indentation counts, and is a part of the syntax !

So you should correct your code this way :

name = str(input("What is your name?"))

if name == "Thomas":
    print("Access granted")
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.