def list_test(): linked_list = LinkedList() linked_list.insert("Noura") linked_list.insert("Jana") linked_list.insert(10) linked_list.append(1222) return linked_list
def zipLists_test(): linked_list_one = LinkedList() linked_list_two = LinkedList() linked_list_one.append(25) linked_list_one.append(1996) linked_list_one.append("birthday") linked_list_two.append(5) linked_list_two.append("my") result = zipLists(linked_list_one, linked_list_two) return result
def zipLists(list_one,list_two): #Edge cases when one of the lists is empty if not list_one: return list_two elif not list_two: return list_one zip_list = LinkedList() current_one=list_one current_one=current_one.head current_two=list_two.head while current_one or current_two: if current_one: zip_list.append(current_one.data) current_one=current_one.next_node if current_two: zip_list.append(current_two.data) current_two=current_two.next_node return zip_list
def zipLists(list_one,list_two): #Edge cases when one of the lists is empty if not list_one: return list_two elif not list_two: return list_one zip_list = LinkedList() current_one=list_one current_one=current_one.head current_two=list_two.head while current_one or current_two: if current_one: zip_list.append(current_one.data) current_one=current_one.next_node if current_two: zip_list.append(current_two.data) current_two=current_two.next_node return zip_list if __name__=='__main__': list_one=LinkedList() list_two=LinkedList() list_one.append(25) list_one.append(1996) list_one.append("birthday") list_two.append(5) list_two.append("my") result=zipLists(list_one,list_two) print(result)
def e_list(): e_list = LinkedList() e_list.append("test") return e_list