I can't seem for figure out how to return a list. (This is for Assignment 3 problem 2). Can someone write out the code for this?
def subStringMatchExact(target,key): x=1 n=0 list=[] while n<len(target): if find(target,key,n)!=-1: list=list+[find(target,key,n)] n=find(target,key,n)+1 else:n=n+1 return list
Ok, I did this. However, I can't use the list. In other words, when I ask Python to print list, I get <type 'list'> and it just types the string. I thought the whole idea was to be able to use the returned values in the rest of the program. I can't seem to do this.
okay, maybe list wasn't the best variable to use. You need to print subStringMatchExact(target,string), not print list
OK, that worked. thanks.
Join our real-time social learning platform and learn together with your friends!