I am new to using the timeit module, and I'm having a hard time getting multi-line code snippets to run inside timeit.
What works:
timeit.timeit(stmt = "if True: print('hi');")
What does not work (these all fail to even run):
timeit.timeit(stmt = "if True: print('hi'); else: print('bye')")
timeit.timeit(stmt = "if True: print('hi') else: print('bye')")
timeit.timeit(stmt = "if True: print('hi');; else: print('bye')")
I have found that I can use triple-quotes to encapsulate multi-line code segments, but I'd rather just type on one line.
Is there any way to use an else statement inside one line in timeit?