I am currently using python version 2.5.4 and every time I try to use the "else" function it I get a syntax error. Why would I get this error? "SyntaxError: invalid syntax" Thanks in advance

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

I am currently using python version 2.5.4 and every time I try to use the "else" function it I get a syntax error. Why would I get this error? "SyntaxError: invalid syntax" Thanks in advance

MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

Can you write out an example?
ok here is an example: I did create the problem myself but in every problem I write else: I always get this same response: >>> limit = 1000 >>> counter = 1 >>> current_number = 1 >>> while counter < limit: is_prime = 1 current_number = current_number + 2 for i in range (2, current_number%i) == 0: is_prime = 0 break if is_prime != 0: counter = counter + 1 if counter == limit: print current_number, "is the 1000th prime number" else: SyntaxError: invalid syntax
The else function is colored in red to show that there is a syntax error there.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Well, here the else: is tabbed incorrectly. It needs to be lined up with the if: if is_prime != 0: counter = counter + 1 if counter == limit: print current_number, "is the 1000th prime number" else: Let me know if that solved it.
yes, that was the problem thanks for the help.

Not the answer you are looking for?

Search for more explanations.

Ask your own question