So I have gotten the program to work, my problem so far is that my solution requires that the output look like this [44, 76, 34, 98, 1, 99] but I keep getting ['1', '2', '3', '5', '6', '7'] if my input was 44 76 44 34 98 34 1 44 99 1 1 1
Trying to convert the final solution into an int and then back into a string does not work, I still end up with quotations.
The point of the code BTW is to remove duplicates from a given input and print it out in a list
def eliminateDuplicates(lst):
newlist = []
for number in lst:
if number not in newlist:
newlist.append(number)
return newlist
def main():
numbers =(input("Enter numbers separated by space: "))
x = ((numbers.split()))
print("The distinct numbers are: ", (eliminateDuplicates(x)))
main()
inputgives you a string andsplitbreaks up a string into a list of strings. Perhaps you can take it from here? List comprehensions?map? Lots of choices for you.