Why I can't apply value inside while loop?

Because “assignments are not expression”, they are statements, like variable declarations or for/while loop.