Oct-29-2018, 11:43 PM
It's best to explain in what way does it not work. Is there some input for which there is an except? If so, provide the input and the full stack trace. If not, is there an input for which there is an undesirable output? It's best to provide the input, desired output, and erroneous output, labeled clearly.
In this case, I can tell that when your if-condition is False, you'll get a NameError. You can either create an else-branch to ensure that [icode]a[/code] is always defined, or you can just return the expression that you're using and skip the whole if-else and variable name. In this case, I suggest you add an else-branch unless you're comfortable with understanding everything I've said here.
In this case, I can tell that when your if-condition is False, you'll get a NameError. You can either create an else-branch to ensure that [icode]a[/code] is always defined, or you can just return the expression that you're using and skip the whole if-else and variable name. In this case, I suggest you add an else-branch unless you're comfortable with understanding everything I've said here.