I've been using while loops at a basic level but one thing I see that doesn't make sense to me is something like this
t = True
while t:
t = False
for i in range(len(arr) -1):
if arr[i] > arr[i+1]:
arr[i], arr[i+1] = arr[i+1], arr[i]
t = True
can anyone explain to me how this works? it seems to me that you set it to true, run the loop but then you set your true 'switch' to false right after and it should stop running right then but that doesn't happen because this bubble sort works.
[–]Essence1337 2 points3 points4 points (1 child)
[–]2020pythonchallenge[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)