129k views
2 votes
You're given a sequence of non-negative numbers on a single line via standard input, each separated by a single space. Print the same list with on a single line on standard output however after removing any element that occurs only once.

Assumptions

1. All the numbers are non-negative (greater than or equal to 0.

2. The only input is the sequence of numbers

3. There are no punctuation marks or anything else to worry about reading.

4. There's at least one number in the sequence which occurs more than once

Example

input 2313
Answer 1313

1 Answer

2 votes

Answer:

We have the following code in Python below with appropriate comments

Step-by-step explanation:

values = input().split() #splitting the standard input

lst = [] #creating an empty list

for number in values:

if values.count(number) > 1: #conditional statement for only considering

#numbers which occur more than once

lst.append(number) #adding the number into the empty list

print(' '.join(lst)) #displays the result

User Sepehr
by
5.5k points