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:
the script is given below:
def fib(n):
   a,b = 0,1
   while a<=n:
      print a
      a,b = b,a+b

for x in fib(4):
   print  x. When i executed this script i am getting this error:
Typeerror:"nonetype" is not iterable
But the same script if 'print' is replaced with 'yield' inside while loop it
is executing properly without any type errors
could any one reply why print cant be used instead of yield and why error is
generated?

--

                                          Vanam
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to