Answers for "syntax of list in python"

1

list in python

fruits = ["apple", "banana", "cherry"]
print(fruits)

fruits[0]
fruits[:2]
Posted by: Guest on June-30-2021
6

python list

#Creating lists
my_list = [1, "Hello", 3.4, 0, "World"]
my_nested_list = [['Hello', 'World'],[47,39]]

#Accessing lists
my_list[1] # Hello
my_list[-2] # 0
my_list[:3] # [1, "Hello", 3.4]
my_nested_list[1] #[47,39]
my_nested_list[0][1] # World
Posted by: Guest on May-21-2020
0

list in python

list = [0,1,2,3,4]     
print("printing original list: ");    
for i in list:    
    print(i,end=" ")    
list.remove(2)    
print("nprinting the list after the removal of first element...")    
for i in list:    
    print(i,end=" ")
Posted by: Guest on May-25-2021

Python Answers by Framework

Browse Popular Code Answers by Language