Prisma interview question

Hacker rank test in python