You are not updating number
in your while
loop so you are stuck in an infinite loop.
You should assign return value of collatz
to number
back, to update number
.
while number != 1:
number = collatz(number)
print(number)
More Related Contents:
- How to handle special cases in my Python code?
- why doesn’t += work in a while true loop python?
- UnicodeDecodeError: ‘charmap’ codec can’t decode byte X in position Y: character maps to
- Unpacking, extended unpacking and nested extended unpacking
- Local variable referenced before assignment?
- PermissionError: [Errno 13] Permission denied
- Python 3.7 anaconda environment – import _ssl DLL load fail error
- How to import members of all modules within a package?
- Difference between except: and except Exception as e:
- What is the naming convention in Python for variable and function?
- Generic[T] base class – how to get type of T from within instance?
- floating point in python gives a wrong answer [duplicate]
- Function chaining in Python
- Selenium gives “selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary” on Mac
- Checking for NaN presence in a container
- Why is a class __dict__ a mappingproxy?
- What is the difference between int() and floor() in Python 3?
- Python map object is not subscriptable [duplicate]
- Changing User Agent in Python 3 for urrlib.request.urlopen
- How to fix “no module named ‘app_one'”
- Python 3 bytes formatting
- Calling Python script from C++ and using its output
- pyvenv-3.4 returned non-zero exit status 1
- Python’s “open()” throws different errors for “file not found” – how to handle both exceptions?
- How to change all the dictionary keys in a for loop with d.items()?
- Anaconda unicode error on command line startup on Windows
- What is the difference between super() with arguments and without arguments?
- Issue with regex backreference in Python
- How do I change the volume of the sound or music in PyGame?
- What difference between pickle and _pickle in python 3?