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


Groups > comp.lang.python > #84687

Re: Python simple Code

References <4e283f62-0b6a-4ef7-a784-b9b3da73f510@googlegroups.com> <0514aac8-943b-4ecc-9ebb-91dd9b58c0f1@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2015-01-27 16:50 -0700
Subject Re: Python simple Code
Newsgroups comp.lang.python
Message-ID <mailman.18194.1422402657.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Jan 27, 2015 at 4:22 PM, Salem Alqahtani <salem055@gmail.com> wrote:
> I appreciate your answers and the output that I am expected from my simple code is the following:
>
> ['salem','Ali','sultan']
> ['salem','sultan','Ali']
> ['Ali','sultan','salem']
> ['Ali','salem','sultan']
> ['sultan','Ali','salem']
> ['sultan','salem','sultan']
>
> the 3 * 2 * 1 is 6 but I do not looking for this output.

>>> from itertools import permutations
>>> a = ['salem', 'Ali', 'sultan']
>>> for p in permutations(a):
...   print(list(p))
...
['salem', 'Ali', 'sultan']
['salem', 'sultan', 'Ali']
['Ali', 'salem', 'sultan']
['Ali', 'sultan', 'salem']
['sultan', 'salem', 'Ali']
['sultan', 'Ali', 'salem']

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