Ive written the code as sir has written it but why dosent it work for me?

there are few small mistakes
i have corrected them and commented the mistake
Modified Code