Cannot understand the exercise solution
Hi , please help. I was working on the exercise and cannot understand the solution. Could you please explain what does the word "sorted" do in this code?
numbers = sorted(numbers)
tot = 0
while numbers[tot] < 20:
tot += 1
Since we will use while loops to go through all the variables in the list based on specific conditions, we have to put in mind that this loop will stop if the condition is met, So if the list is not sorted correctly, the loop will stop at any point and ignoring the remaining variables in the list, so that why we have to sort it out each loop/round to include all variables.
I hope it will help.