I have a list and I am trying to obtain either a set or a list of the unique items in that list. I also need to remove all instances of a specific item from the list, which in this case is 'USD'.
currencies = ['AUD', 'AUD', 'CAD', 'CHF', 'EUR', 'GBp', 'GBp', 'HKD', 'JPY', 'KRW', 'NOK', 'SEK', 'TWD', 'USD', 'USD', 'ZAr']
I initially tried,
foreign_currencies = set(currencies).discard('USD')
but noticed that the function was returning a 'NoneType'.
In order to get it to work, I had to do it in two steps.
foreign_currencies = set(currencies)
foreign_currencies = foreign_currencies.discard('USD')
Can anyone tell me why this is the case and/or explain what I am not understanding about the order of execution? In the first example, is .discard() being called before the set is constructed? Is it something deeper that I am not getting?
EDIT: Although the responses in "Why does list.append evaluate to false?" answer my question, my question was not a duplicate. The question posed was not the same, the answer is.