Is there a way to parse a list to combine 2 elements into 1? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
+ 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