0

Having trouble with my first code, please help :'(

The aim of this code is to identify the factors of a number. factors = [] x = input() a = 0 while True : a = a + 1 if x % a = 0 factors.append(i) x = x / a continue if a == x ** (1/2) break reduce(lambda x, y: x * y, factors) = b x / b = c factors.append(c) print ("The factors of the number is" factors ".")

27th Nov 2016, 6:35 PM
Eric Carlsson
Eric Carlsson - avatar
7 Respuestas
+ 1
You need to define "i" in line7 factors.append(i)
27th Nov 2016, 6:50 PM
Miraç Akif Merttürk
Miraç Akif Merttürk - avatar
+ 1
In python, in if statements you need to use double =, so you need to try again like that : if x%a == 0
27th Nov 2016, 7:02 PM
Miraç Akif Merttürk
Miraç Akif Merttürk - avatar
+ 1
Sometimes, the compiler gives you an error if you do not use ' : ' in the end of the if statements. I recommend you to use ' : ' in the ends. It will probably work for your program
27th Nov 2016, 7:06 PM
Miraç Akif Merttürk
Miraç Akif Merttürk - avatar
+ 1
You're welcome :) Keep coding
27th Nov 2016, 7:10 PM
Miraç Akif Merttürk
Miraç Akif Merttürk - avatar
0
Ok, that is fixed but it points out a syntax error with the equal Sign on line 6. Why is that?
27th Nov 2016, 7:01 PM
Eric Carlsson
Eric Carlsson - avatar
0
Thank you so much. I had forgot to use colon at the end. 😁
27th Nov 2016, 7:09 PM
Eric Carlsson
Eric Carlsson - avatar
0
One last thong though.. Is there anything I should change in the Print statment in Line 15??
27th Nov 2016, 7:15 PM
Eric Carlsson
Eric Carlsson - avatar