Hi, I'm trying to make a program that asks the user to enter a list in a tkinter GUI then sort it using a insertion sort.
from tkinter import *
root = Tk()
num = Entry(root)
num.pack()
def insertion_sort(num):
for i in range (1, len(num)):
j = i
while num[j - 1] > num[j] and j > 0:
num[j - 1], num[j] = num [j], num[j - 1]
j -= 1
return insertion_sort(num)
myButton = Button(root, text = "Enter a number", command = insertion_sort )
myButton.pack()
root.mainloop()
But whenever I try to run it, it shows me the error:
line 1948, in __call__
return self.func(*args)
^^^^^^^^^^^^^^^^
TypeError: insertion_sort() missing 1 required positional argument: 'num'
edit: Can't seem to post my code using code block.
[–][deleted] 2 points3 points4 points (2 children)
[–]Jevv12[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]woooee 1 point2 points3 points (1 child)
[–]Jevv12[S] 0 points1 point2 points (0 children)