0
String searching
I wish to type in a equation in one line, then analyze the string, dividing it in 3 variables, 2x float variables and 1 operator variable. I remember i read it somewhere but i cant remember at all!
3 ответов
+ 4
You can also do this:
a = '12.45 + 3.339'
a1, op, a2 = a.split()
# result:
# a1 -> '12.45'
# a2 -> '3.339'
# op -> '+'
Now it depends on what you are going to do with these results.
An other possible way could be to split to list and then proceed.
+ 3
You can use regex for this, it is described fully in the python3 tutorial
0
Thanks for the answers! I guess its time to learn regular expression then 😁