+ 1

Is there a way to parse a list to combine 2 elements into 1?

right now, am parsing a string into a list i.e., str = (12*2)+(200/25) list =['(' ,'1', '2', ')', '+', '(', '2', '0'. '0', '/', '2', '5', ')'] ok, so what I would like to do is combine the numbers so that i can turn them in to integers, the pull it all back down into a calculable problem. HELP!!! lol here is my code: https://code.sololearn.com/cS4eTs09kwCQ/#py

4th Aug 2017, 5:42 AM
James Barrow
James Barrow - avatar
4 Answers
+ 4
I think you can use eval for your program's purpose: https://docs.python.org/3/library/functions.html#eval
4th Aug 2017, 8:21 AM
BĂ ng Tứ Cường
BĂ ng Tứ Cường - avatar
+ 2
thanks man, much appreciated.
4th Aug 2017, 8:30 AM
James Barrow
James Barrow - avatar
4th Aug 2017, 8:53 AM
James Barrow
James Barrow - avatar
+ 2
You're welcome.
4th Aug 2017, 10:03 AM
BĂ ng Tứ Cường
BĂ ng Tứ Cường - avatar