samedi 4 août 2018

can anyone make bubble sort program more shorter than this? [on hold]

idk how to make it shorter than 6 lines for now in the most simple way

def bubble_sort(num):
  for j in range((len(num)-1)):
     for i in range((len(num)-1)):
       if(num[i]>num[i+1]): num[i] , num[i+1] = num[i+1],num[i]  
  return num
print (bubble_sort(list(input("enter the array/list elements:"))))

Aucun commentaire:

Enregistrer un commentaire