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 ".")
7 Respuestas
+ 1
You need to define "i" in line7
factors.append(i)
+ 1
In python, in if statements you need to use double =, so you need to try again like that :
if x%a == 0
+ 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
+ 1
You're welcome :)
Keep coding
0
Ok, that is fixed but it points out a syntax error with the equal Sign on line 6. Why is that?
0
Thank you so much. I had forgot to use colon at the end. 😁
0
One last thong though.. Is there anything I should change in the Print statment in Line 15??