I have huge list of ip. I have to remove the last octect. only 3 octects are present after removing(xyz.xyz.xyz). In these 3 octects i have to remove duplicates. Please help me out.
1 Answer
you have to provide some code, but I think this is what you need:
IPs = ['111.111.111.111',
'111.111.111.111',
'111.111.111.111',
'111.111.111.111',
]
IPs = [item[:item.rfind('.')] for item in IPs]
IPs = list(set(IPs))
print(*IPs)
You are asking about the very basics, please try to learn them before asking basic questions.
1 Comment
Minions
@NickVitha , it was a quick solution, check it now.