Python: Selection sort After implementing suggestions from an earlier, related question (Python: Insertion Sort), I have written this code. Could you help me to improve this code?

def get_input():
    input_str = input("Enter elements to be sorted: ")
    lst = list(map(int, input_str.split()))
    return lst

def selection_sort(thelist):
    for i in range(len(thelist)-1):
        min_idx = i

        for j in range(i+1, len(thelist)):
            if thelist[j] &lt; thelist[min_idx]:
                 min_idx = j

        thelist[i], thelist[min_idx] = thelist[min_idx], thelist[i]


if __name__ == '__main__':
    input_list = get_input()
    selection_sort(input_list)
    print(*input_list, sep = ", ")
Regarding the code itself I think functions should usually return an output and then this should be printed. It is also worth introducing some way of alerting the user if there input causes an error. I entered
5, -3, 0 and this raised an error because your code splits on spaces not commas. Additionally, you are mapping the list to int so entering a character by mistake breaks the code

Hence saying something like

def get_input():
    input_str = input("Enter elements to be sorted: ")
    try:
        lst = list(map(int, input_str.split()))
    except:
        raise TypeError ("Please enter a list of integers only, separated by a space")
    return lst

def selection_sort(thelist):
    for i in range(len(thelist)-1):
        min_idx = i

        for j in range(i+1, len(thelist)):
            if thelist[j] &lt; thelist[min_idx]:
                 min_idx = j

        thelist[i], thelist[min_idx] = thelist[min_idx], thelist[i]
    return thelist

if __name__ == '__main__':
    input_list = get_input()
    output = selection_sort(input_list)
    print(*output, sep = ", ")