Fórum Debian
First Python Project - Versão para Impressão

+- Fórum Debian (http://www.forumdebian.com.br)
+-- Fórum: Debian (/forum-4.html)
+--- Fórum: Software (/forum-14.html)
+--- Tópico: First Python Project (/thread-28047.html)



First Python Project - shawnturner - 07/05/2017 09:16

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.
References:https://www.bleepingcomputer.com/forums/t/605519/first-python-project/

Explainer Video Example