QrDroid



Sharecodepoint popular queries

Saturday, 1 December 2018

How to count the duplicate integer element in the list by taking value from user in python

What is list in python : list  like a array. A like contain & storage multiple data type at same time like : integer, string and more. 

In this program i will you how to count the duplicate integer element by taking the value from user. Variable are store, num, find, number and dup. User can enter the radom number in the list. User can enter the element which element he want to find. store.count() to count the duplicate element.
store = []
num = int(input('How much integer element you want: '))
find = int(input('Which element you want to find: '))
print('Enter radon number :')
for i in range(1, num+1):
    print('Enter', i, 'number :')
    number = int(input())
    store.append(number)
    dup = store.count(find)

if dup == 0:
    print('\n No Duplicate Element find in the list')
else:
    print('\n',find,'is repeated at', dup, 'Times')

Output :

How much integer element you want: 5
Which element you want to find: 3
Enter radon number :
Enter 1 number :
2
Enter 2 number :
3
Enter 3 number :
4
Enter 4 number :
3
Enter 5 number :
3

 3 is repeated at 3 Times

Process finished with exit code 0

If you have any doubt regarding the example then leave your doubts in the comment box.

0 comments:

Post a Comment

 

Version 20.2.1 - 2016 - 2018 - © Sharecodepoint | Made in India. | Copyright Content