difference between concatenation and string.append() in a list | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

difference between concatenation and string.append() in a list

what is the difference between concatenation and string.append() while both does same operations

28th Sep 2018, 3:30 PM
Shubhanshu Rawat
Shubhanshu Rawat - avatar
3 Answers
+ 6
Append adds element to the end of the list, concatenation chain elements in order it is.
28th Sep 2018, 3:41 PM
Izaak GOLDSTEIN
Izaak GOLDSTEIN - avatar
+ 5
One of the main differences might be that string.append() doesn't exist. Correct me if I'm wrong
28th Sep 2018, 3:44 PM
Anna
Anna - avatar
+ 2
concatenation means simply add two string and you get new string. x='solo' y='learn' print(x+y) #output=sololearn and remember here is no append method for string it is uses for list to append the value in the list at last index. x=[1,2,3] x.append(4) print(x) #output=[1,2,3,4]
28th Sep 2018, 3:58 PM
Maninder $ingh
Maninder $ingh - avatar