使用临时变量存储
class Solution: def duplicate(self , numbers ): # write code here if len(numbers) == 0: return -1 temp_list = [] duplicate_str = "" for i in numbers: if i not in temp_list: temp_list.append(i) else: duplicate_str = i break return duplicate_str