syntax error in python 3.4 [closed] - python

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I am getting a syntax error when I use except: even for simple try: a=0 except: statement
try :
a=0
print(a + 2)
except :
And the error is
SyntaxError: invalid syntax

Your code has indentations errors. It should be like:
try:
a = 0
print (a+2)
except:
#do something

Related

The print statement I use is showing a syntax error, kindly note the error on my code [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
Kindly look at 10th line of this code snippet:
You forgot to close print():
print(txt.read())

i can't seem to understand what is causing the error [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
File "<ipython-input-193-4fdf3d1abd17>", line 1
ConfusionMatrix(y_data, model.predict(y_data() , label= ["not_subscribed", "subscribed"])
^
SyntaxError: unexpected EOF while parsing
You're missing an extra bracket, observe you have an EOF error. Try this
ConfusionMatrix(y_data, model.predict(y_data() , label= ["not_subscribed", "subscribed"]))
The python compiler is pretty friendly, as you can see where the error arrow is pointing to, most of time :)

my code in code chef is showing NZEC error for this part of code [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
In codechef this part of my code shows error ?
n=int(input())
l=[]
for i in range(n):
l.append(int(input())
You made an error with brackets, there is 1 missing
correct answer:
for i in range(n):
l.append(int(input()))

except: invalid syntax after using actionChains [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
i get an error at this part of my code.
try:
actionChains.double_click(driver.find_element_by_xpath("//div[4]/form/div/div").perform()
except NoSuchElementException:
actionChains.double_click(driver.find_element_by_xpath("//form/div[2]/div").perform()
If I remove the second line of the code (actionChains.double_click(driver.find_element_by_xpath("//div[4]/form/div/div").perform()
), it works. But, if I don't It doesn't. Any help is greatly appreciated!
You should add a closing parenthesis to the call to the double_click method:
try:
actionChains.double_click(driver.find_element_by_xpath("//div[4]/form/div/div")).perform()
except NoSuchElementException:
actionChains.double_click(driver.find_element_by_xpath("//form/div[2]/div")).perform()

SyntaxError: invalid syntax (print function) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
>>> x=[]
>>> for i in range(10):
x.append(i)
print(x)
SyntaxError: invalid syntax
I'm working with Python 3.5. I can't seem to get the print function working when it's not part of a loop. "print" gets highlighted as the source of the syntax error, but I can't seem to isolate the cause of the error. It prints perfectly well when part of a while or for loop. It's probably caused by a really silly oversight, and I would really appreciate if somebody could point it out.
If you are typing in console, you need to hit enter twice to end that statement. Which in your case, what you did is, you wrote print inside for without indentation. So it will show syntax error.

Categories

Resources