+ 2
def func(x) res=0 for i in range(x): res+=i return res print(func(4)) how is answer is 6. after running the code line by line, wont return res terminate the loop and return value 0 to print?
4 Answers
0
#first you need to put colon after func ":"
def func(x):
res=0
for i in range(x):
res+=i
#dont use "return" , you need to see resalt, use "print" hear
print(res)
#and then you need just call the func
func(4)
0
jk
0
def g(m,n):
res = 0
while m >= n:
(res,m) = (res+1,m/n)
return(res)
- 1
I get the same return of 0. I am not understanding where 6 fits in.