Why is this not correct? If I print lst1 lst2 they look the same…
def reversed_list(lst1, lst2):
if lst1 == lst2.reverse():
return True
else:
return False
Why is this not correct? If I print lst1 lst2 they look the same…
def reversed_list(lst1, lst2):
if lst1 == lst2.reverse():
return True
else:
return False
.reverse()
modifies the original list, and returns None.
i covered this:
None will not equal lst1
can we not also use .reverse() and compare? is there something wrong with this?
def reversed_list(lst1,lst2):
lst2.reverse()
if lst1 == lst2:
return True
else:
return False
There is no reason why that doesn’t solve the lesson. However if you are trying for efficiency, this goes through the entire list reversing it, then compares them. If we just compared until it caught a mismatch then it would be much faster for something with 10,000+ items in the list.