0

What is the output of this code?

def func(x): res = 0 for i in range(x): res +=1 return res print(func(4)) The output of the code is 6. But I am confused how is it so if i take x as 4?

17th Sep 2019, 10:20 AM
Michael Scofield
Michael Scofield - avatar
2 Réponses
+ 4
You made a mistake somewhere, output will be 4. But if replace 1 on i: output will be 6
17th Sep 2019, 10:53 AM
Mikhail Gorchanyuk
Mikhail Gorchanyuk - avatar
0
answer is 6
28th Feb 2021, 9:35 AM
Sasanka Vikum Vitharana
Sasanka Vikum Vitharana - avatar