0

Please, explain why there is only one value printed in output of this example. Why doesn't range (5) work?

import random def fox(a,b,c): for i in range (a): x = random.randit(b,c) print (x) fox(5,1,6)

14th Feb 2017, 6:21 AM
Sergio
Sergio - avatar
4 Respostas
+ 10
so like Alvaro said, it would be: import random def fox(a,b,c): for i in range (a): x = random.randit(b,c) print (x) fox(5,1,6) keep on being foxy!~ awoo
14th Feb 2017, 6:39 AM
Ahri Fox
Ahri Fox - avatar
+ 3
print(x) is outside the for loop (and outside the function, as well).
14th Feb 2017, 6:33 AM
Álvaro
+ 2
Thanks! You helped a lot!
14th Feb 2017, 6:45 AM
Sergio
Sergio - avatar
+ 1
Thank you so much! Now I realised the importance of line position.
14th Feb 2017, 6:44 AM
Sergio
Sergio - avatar