Unique elements of list within list in python
Posted
by
user2901061
on Stack Overflow
See other posts from Stack Overflow
or by user2901061
Published on 2013-10-20T21:23:59Z
Indexed on
2013/10/20
21:54 UTC
Read the original article
Hit count: 240
We are given a list of animals in different zoos and need to find which zoos have animals that are not in any others. The animals of each zoo are separated by spaces, and each zoo is originally separated by a comma.
I am currently enumerating over all of the zoos to split each animal and create lists within lists for different zoos as such:
for i, zoo in enumerate(zoos):
zoos[i] = zoo.split()
However, I then do not know how to tell and count how many of the zoos have unique animals. I figure it is something else with enumerate and possibly sets, but cannot get it down exactly. Any help is greatly appreciated.
Thanks
© Stack Overflow or respective owner