Para usar a função reduce precisamos importar a função de uma biblioteca: from functools import reduce