Use functions,a menu function that run i a loop.
You always fall back into this function,
which ask if want to run again or quit.
Eg:
You always fall back into this function,
which ask if want to run again or quit.
Eg:
def calc(): print 'Write a number, then press Enter, I will show you the way to 1!' n = int(raw_input('Enter here:')) Steps = 0 while 1 > 0: if n == 1: print '1' break remainder = n % 2 if remainder == 0: print n n = n / 2 if remainder == 1: print n n = n * 3+1 Steps = Steps + 1 answer = '=== it took' answer2 = 'steps to get to 1 ===' return answer, Steps, answer2 def show_options(): print('\n1. Run way to 1!') print('(q) Quit\n') def menu(): while True: show_options() choice = raw_input('Enter your choice: ').lower() if choice == '1': calc() elif choice == 'q': return False else: print('Not a correct choice: {}'.format(choice)) menu()