Ask Your Question

if loop not working

asked 2016-08-03 10:32:40 -0500

nebuckandazzer gravatar image

I have to use an if loop in my program. I am checking the irreducibility of a collection of polynomials. If f(x) is a reducible polynomial, then I want to find its factor. This is my code

if (v==0) f.factor()

But I am getting a syntax error. Can someone help me ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-08-03 11:34:23 -0500

updated 2016-08-03 13:05:36 -0500

You need a colon:

if (v==0): f.factor()

I would actually write this as:

if not f.is_irreducible():

Your assignment of v=f.is_irreducible() doesn't seem to be necessary unless you want to use v several times later. If so, you could do

v = f.is_irreducible()
if not v:  # better than checking v == 0
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-08-03 10:32:40 -0500

Seen: 115 times

Last updated: Aug 03 '16