+7 votes
by (13.6m points)
salary = []
names = []

def swap( A, x, y):
    tmp = A[x]
    tmp2 = E[x]
    A[x] = A[y]
    E[x] = E[y]
    A[y] = tmp
    E[y] = tmp2

Here I created a function to input two parallel arrays, which I use later to sort a list of salaries and names.

def floatInput():
    done = False
    while not done:
        nameIn = input("Please enter the employee name or * to finish: ")
        salaryIn = input("Please enter the salary in thousands for " + nameIn + ": ")
            salaryIn = float(salaryIn)            
            print("Program was expecting a positive integer or floating point number!")
            import sys
        if nameIn == "*":
           done = True
    return names, salary

    print(names, salary)

Here is where I created a function to use bubble sorting on my two parallel arrays.

def bubblesort( A, E ):
    for i in range( len( A ) ):
        for k in range( len( A ) - 1):
            first = k
            second = k + 1

            if ( A[first] > A[second] ):

This is where I am getting my error that there are only 3 positional arguments but 4 were given.

            swap( A, first, second, E )

    print( A )
    temp = input("Hit Enter for the next stenp:/n")

bubblesort(names, salary)

print(names, salary)

2 Answers

+16 votes
by (13.6m points)

try to extend like:

def swap(A, x, y, E):
+13 votes
by (13.6m points)

It seems your swap definition is missing the second array argument. It reads

def swap( A, x, y):

where I guess you meant :

def swap( A, x, y, E):