“Comment effacer une liste dans Python” Réponses codées

Comment effacer une liste dans Python

yourlist = [1,2,3,4,5,6,7,8]
del yourlist[:]
Dr. Hippo

effacer la liste

# clear list
my_list =  [ 11, 22, 33, 44, 55 ]
my_list.clear()
print( my_list )					# [ ]
Impossible Impala

Comment effacer la liste dans Python

thislist = ["apple", "banana", "cherry"]
thislist.clear()
print(thislist)
Programmer of empires

Python List clear ()

# list of cars
cars = ['Benz',('volkswagen','BMW'),'Ford','Ferrari',('volkswagen','BMW')]
numbers= [1,(1,3),5,7,(1,3),3,1,6,(1,3)]

# clear the car list
cars.clear()
print("After clearing the car list = ",cars)

# clear the number list
numbers.clear()
print("After clearing the number list = ",numbers)
Gorgeous Gazelle

Python List clear ()

# list of cars
cars = ['Benz',('volkswagen','BMW'),'Ford','Ferrari',('volkswagen','BMW')]
numbers= [1,(1,3),5,7,(1,3),3,1,6,(1,3)]

# deletes all the elements in the car list
del cars[:]
print("After clearing the car list = ",cars)

# deletes all the elements in the number list
del numbers[:]
print("After clearing the number list = ",numbers)
Gorgeous Gazelle

Réponses similaires à “Comment effacer une liste dans Python”

Questions similaires à “Comment effacer une liste dans Python”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code