+ 1

¿Por qué result = 1? -- ¿Why result = 1?

def raiz(x, y): result = 1 for i in range(y): result = result * x return result print(raiz(2, 3)) https://code.sololearn.com/c0Qjh4wDckL3/?ref=app

6th Aug 2022, 7:57 PM
Josué Varela
Josué Varela - avatar
2 Antworten
+ 3
Suppose result was 0 in the beginning: 0 * x * x * ... would be = 0 So you need to initialize result as 1
6th Aug 2022, 8:02 PM
Lisa
Lisa - avatar
+ 2
Thanks so much, i want to live of this xd
6th Aug 2022, 8:19 PM
Josué Varela
Josué Varela - avatar