I have recently started learning Python and wanted to try bubble sort. I'm getting the desired output, but is there a way to not have the space after the final element?
My Output (0 1 2 4 4 5 7 9 14 18 18 )
The output I want (0 1 2 4 4 5 7 9 14 18 18)
Ignore the brackets, they are to show the space
def bubble(arr):
n=len(arr)
for i in range(n-1):
for j in range(0,n-i-1):
if arr[j]>arr[j+1]:
arr[j], arr[j+1]= arr[j+1], arr[j]
for k in range(n):
print(arr[k],end=" ")