python - How to append a list of strings -


i append list of string in python below:

messages = ["hello","hi"] 

expected output

messages = ["hello","hi","bye"] 

her example have error :

"str object has no attribute "append" "

messages = ["really","hey"] user = ["0.0.0.0"] serv.bind(('0.0.0.0',12800)) msg, addr = serv.recvfrom(1024) msg = msg.decode() user.append(addr) messages.append(msg) 

full code :

chat = ['bienvenu dans le chat de dungeons !','welcome on dungeon\'s chat'] user = ["really","hey"] pseudo = ["foo","this"] isconnect = [0]    serv = socket.socket(socket.af_inet,socket.sock_dgram) user_tab = 0  serv.bind(('0.0.0.0',12800))    while(1):      msg, addr = serv.recvfrom(1024)     msg = msg.decode()      if (msg.find("[pseudo]")!=-1):         firstplace = msg.find("[pseudo]")         secondplace = msg.find("[pswd]")         if firstplace != -1 , secondplace != -1:             pseu = msg[firstplace+9:secondplace]             pswd = msg[secondplace+7:]             print("new client infos ip ",addr, ",pseudo", pseu, "and password", pswd)             user.append(addr)             pseudo.append(pseu)             isconnect.append("1")             send_connect="connect"             serv.sendto(send_connect.encode(),addr) 

>>> l = ["hello","hi"] >>> l.append("bye") >>> l ['hello', 'hi', 'bye'] 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -