0

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
  • 3
    Welcome to SO! Please provide some code you have tried to solve it. SO is for suggesting improvements in code, and not to write the code for you Commented Apr 19, 2019 at 16:24

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

@NickVitha , it was a quick solution, check it now.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.