Thanks to @dmitrypolo
and @Fredrik Bengtsson for their help. It does what i want now! hurray!! lol.
myUniqueList = []
def addToMyUniqueList(x):
if x not in myUniqueList:
print("New item added:", x)
return myUniqueList.append(x)
else:
print("ERROR!!! Item already exists!")
addToMyUniqueList("salt")
print(myUniqueList)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks to @dmitrypolo and @Fredrik Bengtsson for their help. It does what i want now! hurray!! lol.
myUniqueList = []
def addToMyUniqueList(x):
if x not in myUniqueList:
print("New item added:", x)
return myUniqueList.append(x)
else:
print("ERROR!!! Item already exists!")
addToMyUniqueList("salt")
print(myUniqueList)