#Enter any IP from subnet, for example, 192.168.0.1
ip = input('Enter IP: ')
parts = ip.split('.')
print(parts)
a = '.'
start = int(input('Start num:'))
end = int(input('End num: '))
for x in range(start, end + 1):
print(parts[0] + a + parts[1] + a + parts[2] + a + str(x))
The code imports no external module.
ip is a string that holds the value of the IP address entered by the user.
parts is a list of four strings, where each string is obtained by splitting the ip string using the period character . as the delimiter.
a is a string containing a period character.
start and end are two integers that the user enters to specify the range of numbers to append to the IP address.
The for loop iterates over the range of numbers from start to end (inclusive) and prints out the concatenation of the first three elements of parts separated by a, followed by the current number in the loop converted to a string.
No comments:
Post a Comment