Cody Bable

Generation

generate functionWed, 12 Apr 2023

create a main driver than repeatedly calls collatz() and determines the length of the returned list.

def collatz(number): if number % 2 == 0: return number // 2 elif number % 2 == 1: return 3 * number + 1 print('Enter number:') try: n = int(input()) print(n) except ValueError: print('You must enter an integer')

Questions about programming?Chat with your personal AI assistant