可以这样编写程序:list = [] for i in range(50): list.append(random.randint(1,100)) for num in list: if num % 2 != 0: list.remove(num) print(list)