Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'skip:[ 20': 0.04; 'output': 0.05; 'subject:Python': 0.06; 'jan': 0.12; 'itertools': 0.16; 'subject:simple': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; 'subject:Code': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'but': 0.35; 'received:google.com': 0.35; 'expected': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'simple': 0.61; '2015': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=DqgY8W9sehAGC07TS+WvGe9c7iVX2dbt0NAmwDooN08=; b=IC2BrgrNZ8E2rhMmh9NrC01e8s2D4y7xS9/i4RzyaJowwAcL0tes+CZgPCVEwOc1sd medOdEBDZed2fhC/AzBvGK9uuW4c9Sepg6ttI89w9ddxCLV9eT0vTqAw9Q2v+0BO6iMT CBX3G1hqwZrWvVdytGZ8seethQYMeafiJ4gcf7GP172d/3S74fwzirA3XZBstiuPyr2h E888CD+taKbt3zLvXKBr7UAnaW6UnkyW66NUJi+zaIArlWUif07UWlHsUWKRWR6zvKpE YN38n+vMSfVhhEYKiqioDrbeD6g+0GjzHJhVBtjSpWWKiyCMh0MsXgJkXmOjI6Jwa0ub 12BA== X-Received: by 10.67.13.12 with SMTP id eu12mr654864pad.157.1422402654369; Tue, 27 Jan 2015 15:50:54 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <0514aac8-943b-4ecc-9ebb-91dd9b58c0f1@googlegroups.com> References: <4e283f62-0b6a-4ef7-a784-b9b3da73f510@googlegroups.com> <0514aac8-943b-4ecc-9ebb-91dd9b58c0f1@googlegroups.com> From: Ian Kelly Date: Tue, 27 Jan 2015 16:50:14 -0700 Subject: Re: Python simple Code To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1422402657 news.xs4all.nl 2832 [2001:888:2000:d::a6]:44361 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:84687 On Tue, Jan 27, 2015 at 4:22 PM, Salem Alqahtani 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']