You're still struggling with this question because you didn't take your time to read the previous comments here , the solution to this and other question has being posted long ago before new year here , just read previous comments. Remember don't use print , instead use return .