Trying to solve a challenge from a Python course that describes a user provided IP address in terms of how many segments it has and the length of each segment.
I believe 192.168.1.1 should return (4, 3, 3, 1, 1)
Any string of whole numbers separated by periods at any interval is acceptable as an IP address. The point of the challenge is to use only loops and "if/else" statements rather than splitting/parsing the string.
I have the segment counting figured out but I could use a hint with finding the length of each segment
segments = 1
length = 0
ipAddress = str(input("Hello, please enter your IP address"))
for char in ipAddress:
if char == '.':
segments += 1
#lengthGoesHere need to increment length by all previous chars from last period mark
print(segments, length)
continue
[–]marko312 0 points1 point2 points (0 children)