I'm just dabbling in a bit of Python. I want to append items inside a for
loop only if it is not already appended thus creating a list of unique items.
fruits = ["Apple","Banana","Banana","Apple"]
newList = []
for i in fruits:
newList.append([i, i.Color])
print(newList)
Note: Just assume .Color
as a property of fruits for the sake of problem.
I want to perform the unique-fication operation inside the loop itself.
Current Output
[["Apple","Red"], ["Banana","Yellow"], ["Banana","Yellow"], ["Apple","Red"]]
Desired Output
[["Apple","Red"], ["Banana","Yellow"]]