-->
当前位置:首页 > 题库

PROGRAMMING:Delete duplicate values in the list (exercise 4-8, fundamentals and applications of Python programming, Higher Education Society)

Luz5年前 (2021-05-10)题库351
Enter a list, delete the duplicate values, and then output.
###Requirements
Suppose there are k elements with a value in the list, delete the first k-1 elements and keep the last one.
The relative positions of different elements in the list should not be changed.
###Input format:
[element 1, element 2,..., element n]
###Output format:
[element 1, element 2,..., element k]
###Input example:
```in
[4,3,2,3,2,4,True]
```
###Output example:
```out
[3, 2, 4, True]
```
Tip: the eval() function can be used to convert a string in the form of "[1,3,5]" into a list.
Note that the output format should be consistent with the output sample, involving spaces, commas, etc< br>





answer:If there is no answer, please comment