Python If Else Hackerrank Solution Java