Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Python
  3. Question
Python

Python print statement “Syntax Error: invalid syntax” [duplicate]

Asked by Arun Singh Apr 14, 2021 1.6K views 1 answer
Share

About this question

In line number 9 of python code, I am getting a syntax error for the below code:

import hashlib, sys
m = hashlib.md5()
hash = ""
hash_file = raw_input("What is the file name in which the hash resides?  ")
wordlist = raw_input("What is your wordlist?  (Enter the file name)  ")
try:
    hashdocument = open(hash_file,"r")
except IOError:
    print "Invalid file."    # Syntax error: invalid syntax
    raw_input()
    sys.exit()
else:
    hash = hashdocument.readline()
    hash = hash.replace("n","")
My version of Python is:
Python 3.2.2 (default, Sep  4 2011, 09:07:29) [MSC v.1500 64 bit (AMD64)] on win
32
In line number 9 of python code, I am getting a syntax error for the below code:
import hashlib, sys
m = hashlib.md5()
hash = ""
hash_file = raw_input("What is the file name in which the hash resides?  ")
wordlist = raw_input("What is your wordlist?  (Enter the file name)  ")
try:
    hashdocument = open(hash_file,"r")
except IOError:
    print "Invalid file."    # Syntax error: invalid syntax
    raw_input()
    sys.exit()
else:
    hash = hashdocument.readline()
    hash = hash.replace("n","")
My version of Python is:
Python 3.2.2 (default, Sep  4 2011, 09:07:29) [MSC v.1500 64 bit (AMD64)] on win
32


Your answer

1 Answer

More Python discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Python Blogs

Guides, tips and career advice on Python from JanBask experts.