Learning Python: The Ultimate Guide for Beginners to Coding with Python with Useful Tools


How to Remove an Item Using Value



Download 2,02 Mb.
Pdf ko'rish
bet43/126
Sana01.01.2022
Hajmi2,02 Mb.
#285662
1   ...   39   40   41   42   43   44   45   46   ...   126
Bog'liq
Learning Python The Ultimate Guide for Beginners to Coding with

How to Remove an Item Using Value
It is not in every situation that you will know the exact position of a value you want to remove
from your list. Remember, if you identify the value, then you can use the remove()method because
it serves the best option in this situation. Do you remember our previous example where we use the
del function? However, this is different. Let's remove an item from the list of our kitchen_item.
kitchen_item = [“pot,” “kettle,” “fridge,” “dishwasher,” “microwave,” “knife,” “bowls”]
print(kitchen_item)
kitchen_item.remove(kettle)
print(kitchen_item)


In the example above, our aim was to remove the kettle from the list of kitchen items. The output
will be as follow:
[“pot,” “kettle,” “fridge,” “dishwasher,” “microwave,” “knife,” “bowls”]
[“pot,” “fridge,” “dishwasher,” “microwave,” “knife,” “bowls”]
Exercise to Try
The following exercises to try may seem complex; however, the offer you a huge opportunity to
include all the lists we have described in this section.
First list – If you are given the opportunity to invite 10 persons (dead or alive) for a
love feast, who will you invite. Then print a message for each individual, inviting him
or her to your love feast.

Download 2,02 Mb.

Do'stlaringiz bilan baham:
1   ...   39   40   41   42   43   44   45   46   ...   126




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish