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


particular  data  type  the  users  want  to  keep  track  of  in  the  program



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


particular  data  type  the  users  want  to  keep  track  of  in  the  program.
However, to give the users full control, first define an empty list, which will
hold values of the users. With this, you can use the append method to add
new elements to the list created.
Inserting Elements
The second way of adding an element in a list is by inserting the element to
the position you want through the insert() method. You have to specify the
index of both the new element and the value, respectively. For instance, we
want to insert a “spoon” after the microwave item on the list.
kitchen_item  =  [“pot,”  “kettle,”  “fridge,”  “dishwasher,”  “microwave,”


“knife,” “bowls”]
print(kitchen_item)
kitchen_item.insert(3, “spoon”)
print(kitchen_item)
Your output will be:
[“pot,”  “kettle,”  “fridge,”  “dishwasher,”  “spoon”  “microwave,”  “knife,”
“bowls”]
What happened in the example above is that I inserted the value “spoon” at
the third index. The insert method enables us to create a space between the
“dishwasher” and the “microwave” while storing the value “spoon” to the
location created.

Download 2,02 Mb.

Do'stlaringiz bilan baham:
1   ...   36   37   38   39   40   41   42   43   ...   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