Well go through it step by step:

we start with number = 0 (maybe insert this inside the function before the loop so that it is reset with every function call).

Now we check the condition of the while loop number which is 0 should be less then 3. Obviously 0 is less than 3 so we execute the loop:

print string

increase value of number by 1 so now it is 1.

Check the condition of the loop again. Is number less than 3? Yes 1 is still less than 3.

print string

increase value of number by 1 so now it is 2.

Check the condition of the loop again. Is number less than 3? Yes 2 is still less than 3.

print string

increase value of number by 1 so now it is 3.

Check the condition of the loop again. Is number less than 3? No 3 is equal to and therefore no longer less than 3 so the condition is false and you stop looping. When you count the number of printed messages you see one for 0,1 and 2 so you made 3 outputs.