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 ... :-)') 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo