class LinkedList: def __init__(self, val=0, n=None): self.val = val self.next = n def __str__(self): return '[{}]->{}'.format(self.val,self.next) def __repr__(self): return '[{}]->{}'.format(self.val,self.next) def __len__(self): l=self.next c=1 while l is not None: l=l.next c+=1 return c def __ge__(self, other): return len(self) >= len(other) def __reversed__(self): revlist=LinkedList(self.val) l = self.next while l: revlist=LinkedList(l.val, revlist) l=l.next return revlist def cerca(self, x): l=self while l: if l.val==x: return True l=l.next return False def get(self, posiz): l=self while l: if posiz==0: return l.val else: l=l.next posiz-=1 raise(IndexError) l0 = LinkedList() l = LinkedList(5) l1 = LinkedList(10, l) print('l0',l0) print('l',l) print('l1',l1) def gen_list (lista): ''' Prende una lista e ritorna una lista linkata con gli elementi della lista in input ''' l=None for i in reversed(lista): l=LinkedList(i,l) return l def gen_list_r (lista): ''' Prende una lista e ritorna una lista linkata con gli elementi della lista in input ''' l=LinkedList(lista[0]) if len(lista)>1: l.next=gen_list_r(lista[1:]) return l bigl=gen_list([4,7,90,45,89,'kjh','123',{8,9}])