0

I have the list of APIs, Input = [WriteConsoleA, WSAStartup, RegCloseKey, RegCloseKey, RegCloseKey, NtTerminateProces, RegCloseKey]

expected output = [WriteConsoleA, WSAStartup, RegCloseKey, NtTerminateProces, RegCloseKey]

Rakesh
  • 81,458
  • 17
  • 76
  • 113
  • As I see 'RegCloseKey' element has ocurred four times in a list.SO what do you mean by second one in a list? I didn't get you expected output – SRG Dec 27 '19 at 06:34

2 Answers2

0

you can simply convert set(list) i.e. set(Input) to remove all the duplicates.

SRG
  • 345
  • 1
  • 9
0
Input = ["WriteConsoleA", "WSAStartup", "RegCloseKey", "RegCloseKey", "RegCloseKey", "NtTerminateProces", "RegCloseKey"]
Output = []
api=Input[0]
for index in range(1,len(Input)):
    if api!=Input[index]:
        Output.append(api)
        api=Input[index]
Output.append(api)
print(Output)

Try this hopefully it will work in your case.

Vashdev Heerani
  • 660
  • 7
  • 21