Type casting and comprehensions


I dont understand why error is coming and I dont understand the error either. Please explain.