Line 15 has a syntax error, why is that?? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Line 15 has a syntax error, why is that??

The aim of this code is to identify the factors of the inputed number. factors = [] x = input() a = 0 while True : a = a + 1 if x % a == 0 : factors.append(a) #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, 8:01 PM
Eric Carlsson
Eric Carlsson - avatar
5 Antworten
+ 2
you should backscape the " around the word factor or use ' for the whole text print ("The factors of the number is \"factors\".") print ('The factors of the number is "factors".')
27th Nov 2016, 8:16 PM
Gab Bar
Gab Bar - avatar
+ 2
You can assign the result of an expression to a variable and not vice versa: b= reduce(...) and not reduce(...) = b
28th Nov 2016, 10:49 AM
Gab Bar
Gab Bar - avatar
+ 1
line 6 looks OK, maybe there's something wrong with the values
28th Nov 2016, 11:53 AM
Gab Bar
Gab Bar - avatar
0
Thank, that seemed to solve it but now the Line with lambda seem to be acting up. Got any thoughts?? And if you could explain it yhay would be great. Actaully i stolen it after searching for A way to multiply the integrera of a list. Eve wrote this but never explained it. Would you mind??
27th Nov 2016, 8:37 PM
Eric Carlsson
Eric Carlsson - avatar
0
Thank you. That tip worked wonders. I also get a syntax error on line 6 with the equal sign. Do you see anything that is wrong with that??
28th Nov 2016, 11:29 AM
Eric Carlsson
Eric Carlsson - avatar