Answers for "adding element to list python"

0

add an element to list python

a=[8,5,6,1,7]
a.append(9)
Posted by: Guest on May-31-2020
-3

append to lists python

list = ['a', 'b', 'c', 'd']
  print list[1:-1]   ## ['b', 'c']
  list[0:2] = 'z'    ## replace ['a', 'b'] with ['z']
  print list         ## ['z', 'c', 'd']
Posted by: Guest on August-24-2020
0

add items to list python

list.append()
Posted by: Guest on January-15-2021
-1

add to list python

fruits = ["Apple", "Banana"]

# 1. append()
print(f'Current Fruits List {fruits}')

f = input("Please enter a fruit name:n")
fruits.append(f)

print(f'Updated Fruits List {fruits}')
Posted by: Guest on March-10-2021

Code answers related to "adding element to list python"

Python Answers by Framework

Browse Popular Code Answers by Language