It works fine when i run it on my ide. Gives error on submission. Check the last condition please.