In my program to brute force all the factors (not including 1) of a number, there is a syntax error in my while loop. The code looks like this.
The syntax error reads
admin-trs-imac-2:programmingst uff yandong$ python factors.py
File "factors.py ", line 4
while x <= sqrt(int(number ):
^
SyntaxError: invalid syntax
When I take out the colon, I get a syntax error in my if statement, again saying that the colon is invalid syntax.When I take that out, i get another syntax error saying that
admin-trs-imac-2:programmingst uff yandong$ python factors.py
File "factors.py ", line 5
x += 1
^
SyntaxError: invalid syntax
Am i doing something majorly wrong? I cannot figure out what.
(by the way there are indents in the correct places but they do not show up)
(Also the arrow in the syntax error in the while loop should be pointing to the colon)
Code:
number = raw_input(" Enter a number ") x = 2 coollist = [] while x <= sqrt(int(number): if number % loop == 0: coollist.append(x) else: x += 1 print coollist
admin-trs-imac-2:programmingst uff yandong$ python factors.py
File "factors.py ", line 4
while x <= sqrt(int(number ):
^
SyntaxError: invalid syntax
When I take out the colon, I get a syntax error in my if statement, again saying that the colon is invalid syntax.When I take that out, i get another syntax error saying that
admin-trs-imac-2:programmingst uff yandong$ python factors.py
File "factors.py ", line 5
x += 1
^
SyntaxError: invalid syntax
Am i doing something majorly wrong? I cannot figure out what.
(by the way there are indents in the correct places but they do not show up)
(Also the arrow in the syntax error in the while loop should be pointing to the colon)
Comment