Why can't we use use for loop instead of while?

If I am using for loop it is giving me error