Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 10 Online
OpenStudy (anonymous):

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?

OpenStudy (anonymous):

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

OpenStudy (anonymous):

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.

OpenStudy (anonymous):

okay, maybe list wasn't the best variable to use. You need to print subStringMatchExact(target,string), not print list

OpenStudy (anonymous):

OK, that worked. thanks.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!