How can I write a simple Python try block that only check if a function returned as true? -
pretty new python, trying use try/except block tests if output of function true or not. function takes simple input user , validates it. want this:
try: if(test_function()): print('input test_function true.') except: print('input test_function false.')
but can see, never hits except portion of code. how can accomplish this?
this not try/except situation; simple if statement:
if(test_function()): print('input test_function true.') else: print('input test_function false.')
try/except code may raise exception, such as
try: if(test_function()): print('input test_function true.') except: print('test_function tried illegal ... :-)')