I want to print array elements without commas and single lines. I am writing a function to sort an insert. Although it works correctly, it's hard for me to print them correctly. Code I wrote:
#!/bin/python def insertionSort(ar): newNo = ar[-1] for i in range(0, m-1): if(newNo < ar[mi-1]): ar[mi] = ar[mi-1] for e in ar: print e, print '\n' ar[mi-1] = newNo for f in ar: print f, m = input() ar = [int(i) for i in raw_input().strip().split()] insertionSort(ar)
The output I get is:
2 4 6 8 8 2 4 6 6 8 2 4 4 6 8 2 3 4 6 8
I need to get the following code to pass the code:
2 4 6 8 8 2 4 6 6 8 2 4 4 6 8 2 3 4 6 8
ie no extra space between lines. Click here for a detailed description of the problem.
source share