how to clear a list in python
yourlist = [1,2,3,4,5,6,7,8]
del yourlist[:]
how to clear a list in python
yourlist = [1,2,3,4,5,6,7,8]
del yourlist[:]
how to clear the list in python
thislist = ["apple", "banana", "cherry"]
thislist.clear()
print(thislist)
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)
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)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us