Fórum Debian

Versão Completa: First Python Project
Você está atualmente visualizando uma versão simplificada do conteúdo. Visualizar a versão completa com formatação.
I'm attempting the first project from a book I'm trying to learn Python from.

The task was to write a function called 'collatz', with a parameter named 'number'. if number is even, then collatz should print number // 2 and return this value.
If odd then collatz should print and return 3 * number + 1.

Then the task was to write a program that lets the user input an integer, so that collatz keeps getting called with the entered argument, until the return value is 1.

I know I've printed in the loop, rather than the function, but other than that, does it seem ok?

I didn't find the right solution from the Internet.

Explainer Video Example
URL de Referência