Making a collatz program automate the boring stuff

前端 未结 25 2288
一整个雨季
一整个雨季 2020-12-08 11:14

I\'m trying to write a Collatz program using the guidelines from a project found at the end of chapter 3 of Automate the Boring Stuff with Python. I\'m using python 3.

25条回答
  •  爱一瞬间的悲伤
    2020-12-08 11:43

    Your collatz() function should print & return only the next value. (It ends when it returns.)

    The while loop should not be inside the collatz() function.

    You've also got inconsistent variable names (n, number, nnumber), and some important code is commented out.

提交回复
热议问题