Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started