Why is the following code not working?
['I', 'am', 'very', 'busy', 'today']
['I', 'am', 'very', 'am', 'I']
I know I can do it easily with the following but I really want to know why the above code failed:
text="I am very busy today" a=text.split() word=a print(word) word[4]=a[0] word[3]=a[1] word[2]=a[2] word[1]=a[3] word[0]=a[4] print(word)I get this answer which is wrong:
['I', 'am', 'very', 'busy', 'today']
['I', 'am', 'very', 'am', 'I']
I know I can do it easily with the following but I really want to know why the above code failed:
text="I am very busy today" a=text.split() a[::-1]Thanks for your help.