anonymous
  • anonymous
Hi, I'm having a problem with utilizing tuples in Pset 3 Question 2. My code is here: http://dpaste.com/530921/ My problem is that this code creates a nested tuple. For example if I use 'a' as the key, and the target as 'atgacatgcacaagtatgcat', it returns: (((((((0, 3), 5), 9), 11), 12), 15), 19). What do I need to do to my code so it stays as a single level tuple?
MIT 6.00 Intro Computer Science (OCW)
katieb
  • katieb
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

anonymous
  • anonymous
try changing "occurancesStart = occurancesStart, ans" to "occurancesStart = occurancesStart + ans"
anonymous
  • anonymous
Tuples are immutable, meaning you cannot add or subtract elements after creation. One option would be to use a list until your data set is complete, then call tuple on the list.
anonymous
  • anonymous
you can add tuples together and create a single tuple, I've done so in my code. and I've done edited shaneb's code to do so as well, mind you that first post was me speaking before i thought so its wrong I'm not sure whats the etiquette on just completeing someones work for them then posting it first the original variable needs to be a tuple to start so before occurancesStart = ans, you need an occurancesStart = () #an empty tuple second, the correct statement I wanted to post above was occurancesStart = occurancesStart + (ans,) the parens and the comma and important, try it without it and see what i mean. in this instance your not changing a tuple, you are creating a brand new tuple with the contents of the old ones. the change from comma to addition is important as well. I hope this came across clearly, I'm not The best speaker

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
Thanks Nessman! I got it solved now.

Looking for something else?

Not the answer you are looking for? Search for more explanations.