所以我已经让程序工作了,到目前为止我的问题是我的解决方案要求输出看起来像这样[44, 76, 34, 98, 1, 99]
但是['1', '2', '3', '5', '6', '7']
如果我的输入是44 76 44 34 98 34 1 44 99 1 1 1
尝试将最终解决方案转换为 int 然后再转换回字符串不起作用,我仍然得到引号。
顺便说一句,代码的要点是从给定输入中删除重复项并将其打印在列表中
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()