Answered step by step
Verified Expert Solution
Question
1 Approved Answer
def compare(lst1, lst2): if len(lst1) != len(lst2): return False elif(lst1[0] == lst2[0]): return compare(lst1[1:],lst2[1:]) Example output: >>> compare(['ispython',2,3],['ispython',2,3]) True >>> compare(['ispython',2,3],['ISpython',2,3]) False >>> compare(['ispython',2,3],[1,2,3,4]) False
def compare(lst1, lst2):
if len(lst1) != len(lst2):
return False
elif(lst1[0] == lst2[0]):
return compare(lst1[1:],lst2[1:])
Example output:
>>> compare(['ispython',2,3],['ispython',2,3])
True
>>> compare(['ispython',2,3],['ISpython',2,3])
False
>>> compare(['ispython',2,3],[1,2,3,4])
False
The error code Im getting tell me \"list index out of range\". Any help would be really valuable!
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