Alternative Python solution