ĀæPor quĆ© result = 1? -- ĀæWhy result = 1? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
+ 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