I have the following string a = "1.MATCHES_$TEXT$$STRING"
I want to create a function which at some point calls the split function. My function looks like this:
def myfunction(x,splt,sel_nr,col=False):
if(not col):
return(x.split(splt)[sel_nr]
My question is that this: a.split('$')[0:2] works, but this:
myfunction(x=a,splt='$',sel_nr=[0:2],col=False) does not and I do not understand why.
I also tried:
def myfunction(x,splt,*sel_nr,col=False):
if(not col):
return(x.split(splt)[sel_nr]
but it still does not work
I am using python 3.x