DEV Community

Masood
Masood

Posted on

Someone solve this

Take a number "N" from the user and let the user enter a set of numbers exactly equal to N, as
"input_array". Form a list from the given set of array elements. With that list, write a program to
print this list after removing all duplicate values with original order reserved.
a. Create a class for performing the operations. Getting the input, printing outputs can be
done outside the class.
b. If any duplicates are found, raise a user-defined exception. Catch this exception from the
main function and print "Duplicate found at index 1".
c. Make sure that no matter what input is given the program doesn't throw any runtime
Errors.
d. You can get the input from stdin or you can use argparse. Bonus points for using
argparse.
Input 1:
N = 5, input_array = [2,2,3,4,5]
Output 1:
Duplicate found at index 1
Input 2:
N = 5, input_array = [2,3,4,5]
Output 2:
[5,4,3,2]

Top comments (0)