Answers for "append two items to list"

7

append two items to list

my_list = ['a']
# You can use list.append(value) to append a single value:
my_list.append('b')
# my_list should look like ['a','b']

# and list.extend(iterable) to append multiple values.
my_list.extend(('b','c'))
# my_list should look like ['a','b','c']
Posted by: Guest on October-21-2020
-1

python append multiple values

list.extend(val1,val2,val3....)
list.extend( [val1,val2],val3,val4,[val5,val6,val7])
#any combination of integers, strings, lists and tuples works
Posted by: Guest on August-07-2020

Code answers related to "append two items to list"

Python Answers by Framework

Browse Popular Code Answers by Language