I'm a beginner here and could really use some help.
I have to determine whether all elements in a two-dimensional list is unique. For example, if given a two-dimensional list my_list = [[1,2,2],[4,5,2],[7,2,9]], I have to write a code that would say, "this list does not have all unique elements" because of the multiple 2s. I have to write code using nested loops.
Here is what I have so far:
my_list = [[1,2,2],[4,5,2],[7,2,9]]
for row in my_list:
for num in row:
if row.count(num) > 1:
print("Duplicate")
else:
print("No duplicate", num)
This code can detect the duplicate 2 in the first list of my_list, but not the second list.