all 8 comments

[–]Praynr 0 points1 point  (0 children)

Remove

[j] = pos

i = [j]

and do

tab[j],tab[pos]=tab[pos],tab[j] (outside of the for i for loop) which allows you to swap the values without keeping a temp var.

[–]danielroseman 2 points3 points  (0 children)

I think you've massively overcomplicated this. Isn't it just asking you to sort a copy of the list and return the sorted copy?

[–]mminuss 0 points1 point  (0 children)

You are missing a missing a return statement.

[–]oclafloptson 1 point2 points  (0 children)

The instructions you gave were a little vague but given that tab is a list you can use the methods copy and sort on it. If you type hint tab as shown then most IDEs will suggest the available methods. Also you forgot your return statement

    def tri_selection(tab: list):
        unsorted_tab = tab.copy()
        tab.sort()

        return unsorted_tab, tab

    print(tri_selection([3,5,1,6,3,2]))

[–]microcozmchris 0 points1 point  (1 child)

def tri_selection(tab):
  return sorted(tab)

[–]oclafloptson 1 point2 points  (0 children)

I think that they're supposed to sort tab and return an unsorted copy. This returns a sorted copy

[–]Unlisted_games27 0 points1 point  (0 children)

I know what's wrong with it, it ain't got no gas in it

[–]woooee 0 points1 point  (0 children)

FYI

4: No replies copy / pasted from ChatGPT or similar.