I have this code:
def print_trained_network(trained_network):
print("Accuracy on training set:", trained_network['score_training'])
print("Accuracy on test set:", trained_network['score_test'])
print("Execution time", trained_network['time_elapsed'])
print("Best loss", trained_network['best_loss'])
print("n_iter", trained_network['n_iter'])
print("train_shape", trained_network['train_shape'])
try:
print("label", trained_network['label'])
except:
pass
I want to run every print call in a try except pass, like the last one, without having to add many more lines, by surrounding each with the try catch block.
Is there a way to do it?