[OT] Re: Error in following code

Peter Otten __peter__ at web.de
Fri Jun 22 02:36:22 EDT 2007


 zaperaj at gmail.com wrote:

> Im working with python2.2 on red hat linux.
> The following program is supposed to print decreasing numbers from an
> entered number till 1, each decrement being = 1 :
> 
> #! usr/bin/env/python
> 
> def f(n=int(raw_input("enter number: "))):
>      print 'n=',n
>      if n>1:
>              return n*f(n-1)
>      else:
>              print 'end'
> return 1
 
> Though it works fine on the python interpretor, i dont get the
> required output when i write this code in gedit (text editor). The
> output that i get is (where t4.py is the name of the file):
> 
> [root at localhost root]# python t4.py
> enter number: 6
> [root at localhost root]#
> 
> i.e it takes the input but doesn't print anything. If anybody can
> help... Thanx!

Don't do such experiments as root. It's too easy to totally mess up your
machine.

Peter



More information about the Python-list mailing list