coderbyte solution in Python