Small clarification

I solved this problem a few days ago and I just can’t understand the reason why the first submission got WA and the second one got accepted.
All I did in the second submission was interchanging the if, else conditions. Can someone please explain to me the reason behind this?
Here are my two submissions -
Code which got WA - here
Code which got AC - here

Thank you!

It’s because you didn’t print answer as expected in problem.
WA one has space b/w Unlucky and Chef but you aren’t supposed to print it that way.

Lol… silly mistake… thank you!