I wrote this and its working fine with everything but when I have an empty list in a given list(given_list=[[],1,2,3]) it saying index is out of range. Any help?
given_list=[[],1,2,3]
You are assuming given_list has at least 1 element which is incorrect. To avoid index out of range, you may add
if (len(given_list) == 0) return None
to the beginning of your function.