Question: (Python 3.4) 8.17 Implement your own string class myStr that behaves like the regular str class except that: The addition (+) operator returns the sum

(Python 3.4)

8.17 Implement your own string class myStr that behaves like the regular str class except that:

The addition (+) operator returns the sum of the lengths of the two strings (instead of the concatenation). The multiplication (*) operator returns the product of the lengths of the two strings. The two operands, for both operators, are assumed to be strings; the behavior of your implementation can be undened if the second operand is not a string.

>>> x = myStr( ' hello ' )>>> x + ' universe '

13 >>> x * ' universe '

40

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!