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



Download 2,02 Mb.
Pdf ko'rish
bet51/126
Sana01.01.2022
Hajmi2,02 Mb.
#285662
1   ...   47   48   49   50   51   52   53   54   ...   126
Bog'liq
Learning Python The Ultimate Guide for Beginners to Coding with

Forgetting to Indent
A for loop always require indentation; however, if you forget it, Python will remind you. save this
program with magic.py Let us look at the example below.
magicians_name =[“Greg,” “Perpetual,” “Amos”]
magician in magicians_name:
print(magician)
In this code, the third line should be indented but wasn’t. Once the Python interpreter encounters
such statement that should have an indented block but didn’t find any, it indicates an error with the
code as follows:
File “magic.py,” line 3
print(magician)
^
IndentationError: expected an indented block
To solve this error, you have to indent the line of code properly. As simple as this mistake may be,
it can keep you from getting an error each time you run a program.
Besides  forgetting  to  indent,  you  may  forget  to  indent  statements  in  a  loop.  Your  loop  may  run
successfully without any errors, but your output will be different from what you expected. When
this happens, it signifies you are doing several tasks inside your loop and didn’t indent some of the
lines of codes. For instance, you didn’t indent the second line in the magician code that says, “keep

Download 2,02 Mb.

Do'stlaringiz bilan baham:
1   ...   47   48   49   50   51   52   53   54   ...   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