Question: Python pls Create a recursive function def set_tup(tup, key, val): This function returns a tuple and adds a new tuple (key,value) in tup, or if
Python pls
Create a recursive function def set_tup(tup, key, val):
This function returns a tuple and adds a new tuple (key,value) in tup, or if a tuple already exist edit the tuple's value
For example
def set_tup(tup,key,val):
#THIS FUNCTION SHOULD BE RECURSIVE FUNCTION
#NO FOR LOOP ALLOWED
output
a = (('aaron',30),('bishop',40),('chess',50),('knight':60))
print(set_tup(a,'king',40))
output = (('aaron',30),('bishop',40),('chess',50),('knight':60),('king',40))
print(set_tup(a,'knight',40))
output = (('aaron',30),('bishop',40),('chess',50),('knight':40))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
