Question

Write a program that reads a list of integers in the range (0 – 49) and prints out the numbers that does not repeat twice

IN PYTHON

Write a program that reads a list of integers in the range (0 – 49) and prints out the numbers that does not repeat twice.

The first input of the program is the number of integers contained in this list, followed by the integers contained in the list. Print the numbers in in ascending order.

Case 1:

INPUT: 5 2 2 3 3 1

OUTPUT:1

Case 2:

INPUT:6 1 2 1 2 2 2

OUTPUT:2

Case 3:

INPUT:4 3 2 1 2

OUTPUT: 1 3

3

4

3 2 1 2

1

3

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

Explanation:

First number of elements are taken as input.

Then using a loop, all the numbers are appended to a list.

Then using another loop on the sorted list, if the count of element is 1, only then it is printed out.

feel free to comment if you need any help!

Code:


n = int(input())

l=[]

for i in range(n):
num = int(input())
l.append(num)
  
for element in sorted(l):
if(l.count(element)==1):
print(element,end= ' ')

Output:

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!

PLEASE COMMENT IF YOU NEED ANY HELP!

Add a comment
Know the answer?
Add Answer to:
Write a program that reads a list of integers in the range (0 – 49) and prints out the numbers that does not repeat twice
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT