Question: Use python 3 def replace(xs,old,new,limit=None): Given a list xs, replace occurrences of old value with new value. An optional fourth argument limit is an integer
Use python 3
def replace(xs,old,new,limit=None): Given a list xs, replace occurrences of old value with new value. An optional fourth argument limit is an integer states the maximum number of replacements allowed. You should only replace up to the first limit occurrences of old and leave the rest unchanged. When limit==None, there's truly no limit (and we replace all occurrences of old). Negative or zero limit: no replacement.
o Assume: xs is a list; xs could be empty.
o Return None, because the replacement happened in-place.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
