Posts by Nathan • 61 points
2 posts
-
1
votes2
answers138
viewsQ: How to be more cautious when using the Eval function?
I have a function that gets an account and calculates it using the function eval. My question is, how can I be more cautious in using this function ? def calcula(string): if type(eval(string)) in…
-
3
votes2
answers349
viewsQ: How to calculate the result of an arithmetic expression contained in a tuple respecting the operators' precedence?
I have a tuple containing the tokens of an arithmetic expression: ('5', '+', '2', '*', '5'). I tried to calculate the result of the expression, but it is not respecting the precedence of the…