Print Distinct Numbers Write Program Reads Integers Separated Space One Line Displays Dist Q37169649

(Print distinct numbers)

Write a program that reads in integers separated by a space inone line and displays distinct numbers in their input order andseparated by exactly one space (i.e., if a number appears multipletimes, it is displayed only once).

Hint: Read all the numbers and store them in list1. Create a newlist list2. Add a number in list1 to list2. If the number isalready in the list, ignore it.

Sample Run

Enter numbers: 1 2 3 2 1 6 3 4 5 2

The distinct numbers are: 1 2 3 6 4 5

In Python.


Answer


data = input(“Enter numbers: “).split()list1 = [int(x) for x

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.