I have this:
import re
subs = []
def subcons(data):
match = re.search(r'(<[a-z]{3})', data)
if match:
subs.append(match.group(0))
data = data.replace(match.group(0), '')
subcons(data)
else:
print data
return data, subs
input = 'ABC <uvw <xyz some random data'
e, f = subcons(input)
print e
print f
The print statement in the else part of the function prints this:ABC some random data
which is what I want.
The functio, however, returns this:ABC <xyz some random data
not what I want. And:['<uwv', '<xyz']
This is also what I want.
if I try to return the values from within the else nothing gets passed. Any ideas as to whay could cause this?