Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

Is tuple and list compatible? Normally, you can not add a tuple with a list. e.g. >>> a = [1,2] >>> b = (1,2) >>> c = a + b >>> TypeError! But in this class, a tuple + a list = a list! ??? class inteSet: def __init__(self, *number): self.lst = [1] print type(number) self.lst += number print type(self.lst) def insert(self,e): self.lst.append(e) print self.lst newNum = inteSet(23, 34) newNum.insert(3)

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.

Join Brainly to access

this expert answer

SEE EXPERT ANSWER

To see the expert answer you'll need to create a free account at Brainly

the += operator must iterate over the (right side) expression if it is a sequence - behavior similar to extend ``` >>> a = [1] >>> b = (1,2) >>> a += b >>> a [1, 1, 2] >>> a = a + b Traceback (most recent call last): File "", line 1, in a = a + b TypeError: can only concatenate list (not "tuple") to list >>> a.append(b) >>> a [1, 1, 2, (1, 2)] >>> a.extend(b) >>> a [1, 1, 2, (1, 2), 1, 2] >>> ```
You are right. Looks like 'self +=' is more than just 'self = self +' same thing with the operator .iadd - similar to a.externd(b). >>> import operator >>> z = operator.iadd(a, b)

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Not the answer you are looking for?

Search for more explanations.

Ask your own question