printing numbers in python in order -


I have to print all the lists of numbers in the track

So far I have written it: Def lists (list number, i): if i == lane (list number) - 1: print list number other: j list for border [list], list [number], list name [MT] Listings [J] = Listings [J], list [i] list (list number, I + 1) list [i], list [j] = list [j], list [i] lists ([1 , 2, 3], 0)

I will only list each list Bar How can I print can /? If the list is 1,1,2 then it will print some of them twice. How can I prevent this ?

You are not receiving ascending sequence due to swapping. Whenever you swap two elements inside the internal elements that are not next to each other, then listname (i + 1 :) becomes unused and therefore your rotator appears in ascending order. Are not there.

To fix this, you have to swap the i element in the second position which can be swap sub-sequences and do the following:

  Def permutation (list no, i): if i == lane (list number) - 1: print list is not the other: for category j (i, lane (listNum): if j! = I: list name [i], list name [j] = listNum [j], list statement [i + 1: j + 1] = listname [jj j + 1] + listname [i + 1: j] sorting (list, i + 1) # Now swap it back to Jammu ==: List name [i + 1: j + 1] = list name [i + 2: j + 1] + list name [i + 1: i + 2] list name [i], You can sort the  listNum  before starting the algorithm. Unsorted input handle. 


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -