Python编程PTA题解——列表去重

Description:输入一个列表,去掉列表中重复的数字,按原来次序输出
Input:输入仅一行,输入列表
Output:输出仅一行,输出不重复列表元素
Sample Input
[4,7,5,6,8,6,9,5]
Sample Output
4 7 5 6 8 9

a = list(eval(input()))
b = []
for i in a:
    if i not in b:
        b.append(i)
for i in b:
    if i == b[-1]:
        print(i)
    else:
        print(i, end=' ')

你可能感兴趣的:(PythonPTA题解)