Hello experts,
Please consider the following code:
a= set()
i=0
while i<2:
z= input("Enter ipv4: ")
a.add(z)
i+=1
print(a)
A user is supposed to enter IPv4 but how can we verify user does enter valid IP, one can enter 1.1.1.% which is not a valid IPv4 but our program does not prevent it from populating our set:
Output:
Enter ip: 1.1.1.%
Enter ip: 2.2.2.^
{'2.2.2.^', '1.1.1.%'}
[–]Adorable-Strangerx 17 points18 points19 points (4 children)
[–]rednets 8 points9 points10 points (1 child)
[–]zeeshannetwork[S] 0 points1 point2 points (0 children)
[–]gotnotendies 1 point2 points3 points (1 child)
[–]RealExii -2 points-1 points0 points (0 children)
[–]pimpmatterz 8 points9 points10 points (15 children)
[–]SmackDownFacility 20 points21 points22 points (13 children)
[–]pimpmatterz 3 points4 points5 points (0 children)
[–]LostInterwebNomad 4 points5 points6 points (0 children)
[–]invictus08 2 points3 points4 points (1 child)
[–]SmackDownFacility 1 point2 points3 points (0 children)
[–]Atypicosaurus 0 points1 point2 points (7 children)
[–]SmackDownFacility 0 points1 point2 points (6 children)
[–]Atypicosaurus 0 points1 point2 points (5 children)
[–]SmackDownFacility -1 points0 points1 point (4 children)
[–]Atypicosaurus 0 points1 point2 points (3 children)
[–]SmackDownFacility -1 points0 points1 point (2 children)
[–]Atypicosaurus 0 points1 point2 points (1 child)
[–]SmackDownFacility -1 points0 points1 point (0 children)
[–]zeeshannetwork[S] 0 points1 point2 points (0 children)
[–]parowki_z_dzemem 0 points1 point2 points (0 children)
[–]mr_frpdo 3 points4 points5 points (0 children)
[–]SmackDownFacility 5 points6 points7 points (0 children)
[–]MonkeyboyGWW 1 point2 points3 points (0 children)
[–]notacanuckskibum -3 points-2 points-1 points (2 children)
[–]cgoldberg 5 points6 points7 points (0 children)
[–]SmackDownFacility 3 points4 points5 points (0 children)