Όπως γράφει και ο
pmav99 δεν δίνεις ακριβώς αυτό που θέλεις να μάθεις. Παρόλα αυτά δες αυτές τις λύσεις:
>>> thelist = ['A', 'B', 'C']
>>> thelist2 = ['A', 'B', 'C','D', 'E', 'Z']
>>> thelist[-1]
'C'
>>>
>>> thelist2[-2]
'E'
>>> new_list = []
>>> new_list.append(thelist[-1]- thelist2[-2])
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
new_list.append(thelist[-1]- thelist2[-2])
TypeError: unsupported operand type(s) for -: 'str' and 'str'
>>> for item in thelist2:
if item not in thelist:
new_list.append(item)
>>> new_list
['D', 'E', 'Z']
>>> new_list2 = []
>>> new_list2 = list(set(thelist2) - set(thelist))
>>> new_list2
['E', 'Z', 'D']