Hey help me out getting the logic

I am finding the code to be wrong… it would be better if you could share with me the relevant code written in the tutorial.