2) WAP to accept n numbers in an array and display all the unique
numbers present in it using the following method.
boolean checkUnique(int x) To check if x is a unique number or not.
A number is a unique number that starts and ends with the same digit
Answers
Answered by
9
def checkUnique(x):
ints = [n for n in str(x)]
return ints[0] == ints[-1]
nums = [int(n) for n in input("enter nums: ").split()]
unique_nums = [str(n) for n in nums if checkUnique(n)]
print("\n".join(unique_nums))
Similar questions