how to solve ps3 pr2 by using tuple addition.I have used list but have to make use of tuple.As I can remember tuple was immutable data type .

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

how to solve ps3 pr2 by using tuple addition.I have used list but have to make use of tuple.As I can remember tuple was immutable data type .

MIT 6.00 Intro Computer Science (OCW)
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

here is my code http://dpaste.com/698943/
Good question - this is a quirky syntactical aspect of Python. So, all you have to do is change your list brackets to parentheses and then - here's the catch - you have to put a comma after index on this line: tuplle += (index,) When adding single elements to tuples, you'll always need this comma after the element you are adding. I think, also, that your code won't work for every case as it stands. It needs a (very) minor tweak... my not-so-cryptic-hint: what happens if the key is a single letter and it appears as the last letter of the target?
good answer swdalb. But I don't get what you're trying to say in the second part. Try this: print subStringMatchExact('abcd','d')

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Hmm yeah thanks maitre_kaio I didn't check the code before posting - sorry welldone_boy!, your code works - I just have some bad conception of counting positions in lists. For what it's worth (not much), this is pretty enlightening for me. I *thought* it wouldn't go into the while loop (or would kick out too soon) in exactly the kinds of cases that your suggestion is an example of. I thought that, in your example, index=find('abcd', 'd') would make index = -1, but it defaults to 3 instead (which is the same position in this case)... any reason why it defaults to the positive number rather than the negative? My guess is that it first goes through the string from left to right and then comes back from right to left using negative integers... for ex: find('dabcd', 'd', 5) == -1, not -5 or 0 or 4. maitre_kaio, can you confirm this and/or explain better?
find(target, key) returns the first position (i.e a number >= 0) if key is in target, or -1 if key isn't in target. Here the negative number has the same meaning as None.
Thank you guys!

Not the answer you are looking for?

Search for more explanations.

Ask your own question