Playing with while/if  and expecting output