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

(using python3.x) fall 2008, problem set 3, problem 4(+2+3): I've got the two tuples : the one with exact matches (x), and the other one with up to one different letter(y), but I can't figure out how to get the tuple : (x U y) \ x I'm really curious, please help me :DD

OpenStudy (anonymous):

Sorry, I forgot this: http://paste.org/65157

OpenStudy (anonymous):

i think the idea is to re-use functions that you have already written and tested: subStringMatchExact(), subStringMatchOneSub() then create a tuple that has elements from MatchOneSub that are not in MatchExact there are a number of ways to do this: the 'not in' operator might be useful http://docs.python.org/3/reference/expressions.html#not-in sometimes it is easier to work with lists because they have so many methods - a = list(tuple) do stuff with a a = tuple(a) have you read about displays? http://docs.python.org/3/reference/expressions.html#displays-for-lists-sets-and-dictionaries http://docs.python.org/3/tutorial/datastructures.html#list-comprehensions

OpenStudy (rsmith6559):

FWIW, the 2008 course uses Python 2.5. Python 3.x is significantly different than Python 2.x.

OpenStudy (anonymous):

thanks for your replies, and I do know that python3.x is different but I thought it would be reasonable to use the lateset version

OpenStudy (anonymous):

did you solve it?

OpenStudy (anonymous):

Yes I did, if you are interested: http://paste.org/65336 It seems to work just fine, but I just saw your question wether i did it and so i suddenly felt an urge to do it right now at 1am:DD btw I have moved on and I've finished ps6 today

OpenStudy (anonymous):

here's mine http://dpaste.com/1246455/

OpenStudy (anonymous):

another way would be to turn the tuple into a set and find the difference - http://docs.python.org/2.7/library/stdtypes.html#set.difference

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!