Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #84536

Re: Python simple Code

From Terry Reedy <tjreedy@udel.edu>
Subject Re: Python simple Code
Date 2015-01-24 20:15 -0500
References <4e283f62-0b6a-4ef7-a784-b9b3da73f510@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.18119.1422148807.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 1/24/2015 7:16 PM, Salem Alqahtani wrote:
> Hi Guys,
>
> I just joined the group and I hope that I can help and be active.
>
> I have a question about python. I wrote a code on python 2.7 and I want to choose from the list of names that I provide n!. I execute the code but the result or output is the numbers. I want the people names are the result.
>
>
> Sincerely
>
> import sys
> import array
> a=['salem','Ali','sultan']
> m = len(a)
> def Factorials(m):
>      if m == 0:
>          return 1
>      else:
>          print m
>          return m * Factorials(m-1)
> def output():
>      print a
> def main():
>      print Factorials(m)
>      output()
> main()

When I copy, paste, and run this in Idle editor, I get the expected
 >>>
3
2
1
6
['salem', 'Ali', 'sultan']

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Python simple Code Salem Alqahtani <salem055@gmail.com> - 2015-01-24 16:16 -0800
  Re: Python simple Code Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-25 00:38 +0000
    Re: Python simple Code Rick Johnson <rantingrickjohnson@gmail.com> - 2015-01-26 19:26 -0800
  Re: Python simple Code Terry Reedy <tjreedy@udel.edu> - 2015-01-24 20:15 -0500
  Re: Python simple Code sohcahtoa82@gmail.com - 2015-01-26 10:13 -0800
  Re: Python simple Code Salem Alqahtani <salem055@gmail.com> - 2015-01-27 15:22 -0800
    Re: Python simple Code Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-27 16:50 -0700
      Re: Python simple Code Salem Alqahtani <salem055@gmail.com> - 2015-01-27 17:35 -0800
    Re: Python simple Code Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-28 03:15 +0000

csiph-web