Is there any difference between yield and print in python script?i have written a script based on fibonacci series where in i used yield and print in two different scripts:<br>the script is given below:<br>def fib(n):<br> a,b = 0,1
<br> while a<=n:<br> print a<br> a,b = b,a+b<br> <br>for x in fib(4):<br> print x. When i executed this script i am getting this error: Typeerror:"nonetype" is not iterable<br>But the same script if 'print' is replaced with 'yield' inside while loop it is executing properly without any type errors
<br>could any one reply why print cant be used instead of yield and why error is generated?<br clear="all"><br>-- <br> <br> Vanam