Ask Question

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

+4
Answers (1)
  1. 11 July, 14:12
    0
    We have the following code in Python below with appropriate comments

    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
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “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 ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers