0

I dont know what goes wrong in this piece of code?!!
I keep getting the following error.

File "<stdin>", line 11
t1.append(list[temp])
^
SyntaxError: invalid syntax

tl = []
for inlist in token_list:
    temp=[]
    for token in inlist:
        temp.append((zlib.adler32(token,65521))
    tl.append(temp)
6
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by Gribouillis
Featured Replies
  • 1

    t-one or t-el? Maybe there would exist clearer variable names? By the way have you learned about list comprehensions? Read More

  • 1

    [QUOTE]File "<stdin>", line 11 t1.append(list[temp]) [/QUOTE] "list" is a function so it should be t1.append(list(temp)) In the future, if there is an error for a compound statement, break the statement into it's individual parts to see which part is causing the error. Read More

1

Hey,
I'm new to programming so this may be wrong or not what you want.

tl = []
for inlist in token_list:
    temp=[]
    for token in inlist:
            temp.append(zlib.adler32(token,65521)) #You had an extra (
            tl.append(temp)

And from what it says now you need to define token_list

Is that all of your code?

Sorry if this is wrong :)

Comments
you're right, there is an extra (
1

t-one or t-el? Maybe there would exist clearer variable names? By the way have you learned about list comprehensions?

1

As Shlaa said you have an extra "(" on line 5.
The interpreter thinks that the statement continues in the next line, and finds no closing ")" token.

1

File "<stdin>", line 11
t1.append(list[temp])

"list" is a function so it should be
t1.append(list(temp))
In the future, if there is an error for a compound statement, break the statement into it's individual parts to see which part is causing the error.

0

t-one or t-el? Maybe there would exist clearer variable names? By the way have you learned about list comprehensions?

t-el!!!!!

@everyone: yup. that "(" was making the problem.. i was working continuously for 20+ hours and my mind was all f***ed up!!! I had some nice sleep.. and then i could figure this out easily...
Thanks everyone for the help!

Edited by knan: n/a

0

t-el!!!!!

@everyone: yup. that "(" was making the problem.. i was working continuously for 20+ hours and my mind was all f***ed up!!! I had some nice sleep.. and then i could figure this out easily...
Thanks everyone for the help!

Mismatched parentheses have a high probability when a SyntaxError is raised.

This article has been dead for over six months. Start a new discussion instead.
Take the time to help us to help you. Please be thoughtful and detailed and be sure to adhere to our posting rules.