0
python heelp
import random def rand50(): rand=[random.randrange(0, 255) for i in range(4)] return rand print((rand50()) but i need using def and return random ip adress and then print 20 ip adress . IP must be like this: 192.168.0.1
6 odpowiedzi
+ 1
from random import randint
network = "10.20.30."
for ii in range(20):
ip = network + str(randint(0, 255))
print(ip)
# Obviously you can add elaboration
# like dupe-checking, etc.
# This is just for a general idea.
+ 1
# More or less @ 02h00...
from random import randint
def newIP(netw):
ip = netw + str(randint(0,255))
return ip
for ii in range(20):
print(newIP("192.168.0."))
# The rest can be figured out with
# minor effort + research.
+ 1
Thank you so much
0
The question is unclear. May I assume you want 20 random IP addresses and you want them on the same network? K1.K2.K3.N basically?
0
Yes
0
sorry, but i not exactly understand how to write this by making function(def)