Search code examples
pythonblock

Getting expected an indented block error


def main():
    name = input("Enter Your Name:")
    name2 = input ("Enter Your Name:")
    if (name == 'Mark') & (name2 == 'John'):
        print("Your Name is correct")

main()

This is the simple code I wrote, just for learning Python. But, I'm getting the error every time. How should I fix this?


Solution

  • I believe your print statement was originally out of alignment, as it was not getting picked up by your if statement. Also your & should be and:

    def main():
        name = input("Enter Your Name:")
        name2 = input ("Enter Your Name:")
        if (name == 'Mark') and (name2 == 'John'):
            print("Your Name is correct")
    
    main()