Xiaobai learn python#Day4 (don’t complain)

When the National Day meets the Mid-Autumn Festival, it is the reunion of the whole country to celebrate the whole family. I don't know if you went home today! Anyway, it took ten hours for the three-hour drive to go home. . .

But there was nothing to complain about. I saw a passage on a certain sound and it felt great.

Sharing~

"If you think your country Z is not good enough, you will build it. If you think ZF is not good enough, you will take the civil service examination. If you think the people are not good enough, then you will start to be a qualified citizen. If you feel that your compatriots are ignorant, ignorant, complaining, and fleeing, start learning from your side and change the people around you, instead of just complaining.
The place where you stand is where you live, and it is what makes your heart blossom local."

Closer to home, return to python, return to our for loop

In the for loop, I don't want to repeat every sentence, what should I do?

First line indent! ! !

Insert picture description here
Insert picture description here

Avoid unnecessary indentation errors

number1: Forgot to indent (the print on the next line is a subsidiary of the for loop, so it must be indented)
Error example:
Insert picture description here
Insert picture description here
Correct demonstration:
Insert picture description here
Insert picture description here
number2: Forgot to indent additional lines of code (the execution will not go wrong, but there is a logical error, expected The effect will not be achieved)
Error example: (ps: see the first two pictures in this article)

Proper demonstration:
Insert picture description here
Insert picture description here
(note that the for loop will not be performed without indentation, so that only the last line has a situation)

number3: Unnecessary indentation (not a for loop statement, there is no need for indentation, don't forget the front when you learn the for, the mindset is not necessary)
Wrong demonstration:

Insert picture description here

Insert picture description here
Demonstrate correctly:
Insert picture description here
Insert picture description here

We know that computer languages ​​are very rigorous, and they don't recognize any programmer and are selfless.

In addition to the indentation in the for loop, also pay attention to the colon! !
Insert picture description here
Looks fine, right, come on, execute it.

Oh, oh, oh, oh, oh, oh, oh
Insert picture description here
, it’s wrong, what's the matter?

Classmate, where is your colon?

What? colon?

Here,Here!!!

Insert picture description here

Make arrangements quickly.
Insert picture description hereInsert picture description here

A small mistake is likely to cost Shuaishuai a lot of time, and after understanding these mistakes, will it be much more convenient next time? !

Give a thumbs up and support it.

Guess you like

Origin blog.csdn.net/m0_46565226/article/details/108897092