-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubnetter.py
More file actions
51 lines (22 loc) · 868 Bytes
/
Subnetter.py
File metadata and controls
51 lines (22 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# okay , we give wack, then get subnet mask, more features in future
def num_input(input_num):
num = int(input_num)
numberofbytes= num//8
if num%8 == 0:
return "255."*(numberofbytes-1)+"255" + ".00"*(4-numberofbytes)
else:
stringof255 = "255."*numberofbytes
stringof0s = ".00"*(3-numberofbytes)
loop = num%8
numberofmask = ''
valueformask = 0
for x in range(7,7-loop,-1):
valueformask += 2**x
return stringof255+str(valueformask)+stringof0s
def main():
x = str(100)
while x is not str(99):
x = input("please enter /X number ...")
print(num_input(x))
# where the magic happens
main()