Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

TypeError: insertionSort() got an unexpected keyword argument 'numberList'

i am doing my assigment in python i need to creat function for insertion sort which take input in float and do insertion and also do print list of sorting after every single index is sorted please dont delete post i am newbe and dont understand other solution guide me please
i need to input exactly name

insertionSort(numberList=[1.1, 2.2, 3.3, 4.4])

my function is

def insertionSort(intList):
    n = len(intList)
    for i in range(0, n-1):

        kMin = i
    for k in range(i+1, n):
        if (intList[k] < intList[kMin]):
            kMin = k

    if (kMin != i):
        temp = intList[i]
        intList[i] = intList[kMin]
        intList[kMin] = temp

my output need to be exactly like this

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

**round 1 start: [1.1, 2.2, 3.3, 4.4]↩

round 1 end: [2.2, 1.1, 3.3, 4.4]↩

round 2 start: [2.2, 1.1, 3.3, 4.4]↩

round 2 end: [3.3, 2.2, 1.1, 4.4]↩
round 3 start: [3.3, 2.2, 1.1, 4.4]↩
round 3 end: [4.4, 3.3, 2.2, 1.1]**

>Solution :

You say insertionSort(numberList=[1.1, 2.2, 3.3, 4.4]), but the definition of insertionSort expects a parameter named intList. Either change the name you pass to match the prototype:

insertionSort(intList=[1.1, 2.2, 3.3, 4.4])

change the definition to use the better name (since it clearly works on float):

def insertionSort(numberList):  # And change all uses inside the function to numberList

or just have the caller pass positionally so the name doesn’t matter:

insertionSort([1.1, 2.2, 3.3, 4.4])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading