Everyone, I wrote this simple program (to learn python) that prints a list of messages and then fills a new list of printed message. It's very easy code , but something goes wrong with for loop.
The code is :
def Print_It (message):
print (message)
def Send_mex (To_send):
for sende in To_send:
Print_It(sende)
current_message = List_of_Message.pop()
Sended_message.append(current_message)
List_of_Message = ['GO!!!', 'WAIT!!!', 'DAMN!!', 'OUCH!!!']
Sended_message = []
Send_mex (List_of_Message)
Print_It (List_of_Message)
Print_It (Sended_message)
The Output is:
GO!!!
WAIT!!!
['GO!!!', 'WAIT!!!']
['OUCH!!!', 'DAMN!!']
The expected output is:
GO!!!
WAIT!!!
OUCH!!!
DAMN!!!
[]
['OUCH!!!', 'DAMN!!','GO!!!', 'WAIT!!!']
for some reasons that I don't understand the for loop works only for two arguments of list not for all...
Any suggestions?