Methods to add data to the lists
Methods to Add Data to the Lists
string = ["string1", "string2"]
#append
string.append("string3")
print(string)
#insert
string.insert(1, "string3")
print(string)
# Joining two lists
list_2 = ["string3", "string4"]
list_3 = string + list_2
print(list_3)
# extend
string.extend(list_2)
print(string)
string.extend("string3")
print(string)
string.append(list_2)
print(string)
Post a Comment