I've got something like this:
a = '2(3.4)'
b = '12(3.5)'
I only want the value inside the brackets. I used regex, and it worked, but my teacher won't allow it. How can I do this?
I've got something like this:
a = '2(3.4)'
b = '12(3.5)'
I only want the value inside the brackets. I used regex, and it worked, but my teacher won't allow it. How can I do this?
>>> a, b = '2(3.4)', '12(3.5)'
>>> def extract(string, start='(', stop=')'):
return string[string.index(start)+1:string.index(stop)]
>>> extract(a), extract(b)
('3.4', '3.5')
>>>