#Convention to make function comments as commands def collatz(number): """Return the value 1!!!!""" if number%2 == 0: print number//2 return number//2 #Integer division else: print (3*number)+1 return (3*number)+1 try: user_num = int(input("Enter an integer: ")) print(user_num) except NameError: print('You must enter an integer.') while user_num != 1: user_num = collatz(user_num)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question