Sep-28-2018, 05:01 AM
I have, in the same directory, created a file SecretPasswordFile.txt with a word placed inside as the password key.
Next, I created this file:
I have checked most of the commands by typing them individually on the python console or IDLE.
But when I try to run this file, I get error msg:
For example,
Next, I created this file:
#! /usr/bin/env python passwordFile = open('SecretPasswordFile.txt') secretPassword = passwordFile.read() print('Enter your password') typedPassword = input() if typedPassword == secretPassword: print('Access granted') if typedPassword == '12345': print('That password is one that an idiot puts on their luggage.') else: print('Access denied')
I have checked most of the commands by typing them individually on the python console or IDLE.
But when I try to run this file, I get error msg:
python3.3 add.py File "add.py", line 7 print('Access granted') ^ IndentationError: expected an indented blockWhy am I receiving the above error messages?
For example,
$ python Python 2.7.3 (default, Jan 2 2013, 16:53:07) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> python3.3 Python 3.3.2+ (default, Jun 13 2013, 13:47:13) [GCC 4.8.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> print ("hello") hello >>> print('hello') hello >>> print ('hello') hello >>> print("hello") hello >>>