Errors when doing an exception with requests in python

I've been searching for the reason behind my issue to no avail. It worked before I added the exception handler so I'm relatively perplexed. I am new to python, JSON, APIs, and sql, but not to programming.

def getSyllables(word):
conn = sqlite3.connect("wordbase.db")
c = conn.cursor()
c.execute('SELECT * FROM words WHERE Word =?', [word])
syllables = 0
if (c.fetchone() == None):
    url = '' + word
        r = requests.get(url)
        j = json.loads(r.text)
        rememberSyllables(word, int(j['syllables'])
        syllables = int(j['syllables'])
    except requests.exceptions.RequestException as e:
        syllables = 0
    syllables = c.fetchone[1]
return syllables

The error I get now is:

syllables = int(j['syllables'])
SyntaxError: invalid syntax

And if I remove that (Even though I'm fairly certain that the syntax is correct?):

except requests.exceptions.RequestException:
SyntaxError: invalid syntax



The problem is very simple, you haven't closed the previous line's parentheses:

rememberSyllables(word, int(j['syllables']))

This should solve the problem.

rememberSyllables(word, int(j['syllables'])) Here the extra ) would solve the issue!!

Need Your Help

Time format when using pandas.to_csv()

python pandas dataframe

I have a out put from a Pandas DataFrame as following.