Python - Como resolver este ejercicio?

 
Vista: