I’m facing a problem with my script:
I would like to store a string inside a list and increment this list with these strings.The string is retrieved from a server response.
This could be resumed like this in Python:
import socket
from socket import *
host = "10.0.0.23",445
def Test(host):
s = socket(AF_INET, SOCK_STREAM)
s.connect(host)
s.settimeout(30)
string ="Test"
s.send(string)
data = s.recv(2048)
StringToStore = data[0:5]#Important: Values returned are random.
return StringToStore
def ListIncrement(T):
for x in range(5):
ListStr = Test(host)
ListValue = list(ListStr)
return ListValue
Testing = ListIncrement(Test)
print "Testing if ListIncrement returned a list of 5 differents strings :", Testing
This is clearly not working for some reasons i can’t figure, but what I would like ListIncrement(T) to return is an array like this :
['1234','4321','3214','2314','4322']
Thanks much in advance !
You probably meant to do something like:
This could also be done as a list comprehension: