[Tutor] Using Python to solve factoria

Alan Gauld alan.gauld at yahoo.co.uk
Thu Dec 22 04:47:48 EST 2016

On 21/12/16 07:50, Hedgar wrote:

> I really happy to be accepted to the list!

You're welcome, but one very important thing to
note is that you should always post to this list
in plain text, not HTML. That's because HTML loses
the formatting of the code (see below) and in
Python formatting is very important.

> def factoria(numb):
> While numb > 1:
> If numb==0:
> return 1
> Else:
> result = numb*(numb-1)
> numb = numb -1
> return result
> factoria(5)

As you see we lost formatting, however this code
would never run because it is not valid Python.
Python is case sensitive so you need to use
'while' not 'While' etc.

> #should output 120
> What am I not getting right?

Another important point when postring is to
always include any error messages(in full)
that you get. They contain vital clues as
to what is wrong.

I see Bob Stepp has replied re the actual code,
so I assume his mail reader managed to interpret
it correctly - or maybe he just guessed. But
following the above guidelines will help you
get good answers more quickly in future.

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list