Answer to Question #290228 in Python for pooja

Question #290228

given a list of numbers find and print the first number that occurs only once in the list and the first number that occurs more than once in the list



sample input 1:


5 5 4 7 4 1 11


sample output 1:


7


5



sample input 2:


1 2 3 4 5 6 7 8 9


sample output 2:


1


None

1
Expert's answer
2022-01-24T12:28:27-0500
if __name__ == '__main__':
   data = [int(i) for i in input().split()]

   uniq_number = None
   repeate_number = None

   for i in data:
       if data.count(i) == 1:
           uniq_number = i
           break

   for i in data:
       if data.count(i) > 1:
           repeate_number = i
           break

   print(uniq_number)
   print(repeate_number)

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