Answer to Question #103353 in Python for Neve

Question #103353
How can I check if there are any unique items in a list
1
Expert's answer
2020-02-20T07:46:47-0500

a=[1, 2, 3, 4, 4, 4, 5, 6, 5, 6]

c=0

for i in range(len(a)):

if a.count(a[i]) == 1:

print('YES', a[i])

c=1

if c == 0:

print('NO')


For example, we have list of digits 1, 2, 3, 4, 4, 4, 5, 6, 5, 6 and c=0

In the loop we check the count of each digit in the list. If it is unique, program output 'YES' and unique digit than c become equal 1. But if there are not unique objects, program output 'NO'


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS