By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,462 Members | 799 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,462 IT Pros & Developers. It's quick & easy.

how to create a list of lists while swaping items

P: 1
I have a list

L1= [1,2,3,4]
I want to generate a list of list, but I have to start by swaping 1 with every posible number I can swap it with. So if start with 1 , I get

L1 = {2, 1, 3, 4}
L2 = {3, 2, 1, 4}
L3 = {4, 2, 3, 1}

Then I start swaping 2 from the orginal list L1

L3 = {1, 3, 2, 4}
L4 = {1, 4, 3, 2}

and so on.

How can I create somethin like this in python.
Sep 18 '17 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,365
What have you tried so far?
Sep 19 '17 #2

Post your reply

Sign in to post your reply or Sign up for a free account.