Skip to content

Commit 0e1f0ca

Browse files
committed
Update basic_operation.py
1 parent 4266ddd commit 0e1f0ca

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

General/basic_operation.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
import socket
2+
3+
#Remove Duplicates from list - Input (ipaddress)1 | Output (status)1
4+
def validate_ip_logic(ip_address):
5+
valid_host=ip_address.split(".")
6+
len_host=len(valid_host)
7+
if (len_host<4) or (len_host>4):
8+
status=False
9+
elif len_host==4:
10+
for i in valid_host:
11+
if (int(i)<0) or (int(i)>255):
12+
status=False
13+
break
14+
if valid:
15+
status=True
16+
return status
17+
18+
#Remove Duplicates from list - Input (ipaddress)1 | Output (status)1
19+
def validate_ip(ip_address):
20+
status=""
21+
try:
22+
socket.inet_aton(ip_address)
23+
status=True
24+
except socket.error:
25+
status=False
26+
return status
27+
128
#Remove Duplicates from list - Input (list)1 | Output (list)1
229
def remove_duplicate_list(input_list):
330
output_list = list(set(input_list))

0 commit comments

Comments
 (0)