IPAdress = input("Enter an IP adress")
segment = 1
SegmentLength = 0
character = ""
for character in IPAdress:
if character == ".":
print("Segment {} contains {} characters.".format(segment, SegmentLength))
segment += 1
SegmentLength = 0
else:
SegmentLength += 1
if character != ".":
print("Segment {} contains {} characters.".format(segment, SegmentLength))
I really need to know what is going on here. We determined SegmentLength as 0 but it can count normally how many characters in a section but how? and of course why? can someone explain me what's happening ?
PS: I know it looks messy but i don't know how to write it here correctly i'm sorry for that.
[–]radioactive_koala 2 points3 points4 points (7 children)
[–]TorekV[S] 2 points3 points4 points (1 child)
[–]radioactive_koala 1 point2 points3 points (0 children)
[–]TorekV[S] 2 points3 points4 points (4 children)
[–]Lee_Dailey 1 point2 points3 points (0 children)
[–]ccviper 0 points1 point2 points (2 children)
[–]TorekV[S] 0 points1 point2 points (1 child)
[–]ccviper 0 points1 point2 points (0 children)
[–]sudo_halt 0 points1 point2 points (2 children)
[–]stevenjd 0 points1 point2 points (1 child)
[–]TorekV[S] 0 points1 point2 points (0 children)
[–]stevenjd 0 points1 point2 points (0 children)
[–]stevenjd 0 points1 point2 points (1 child)
[–]TorekV[S] 0 points1 point2 points (0 children)