[Tutor] Noob: nested if-clauses
Joel Goldstick
joel.goldstick at gmail.com
Sun Jan 24 16:05:36 EST 2016
On Sun, Jan 24, 2016 at 2:42 PM, STF <lapsap7+python at gmail.com> wrote:
> Hi,
>
> I've just started to learn Python thru some online courses and websites.
> They just teach very basic things. I've got some questions about "if" that
> I'm unable to find the answers. So let me ask the newbie questions here.
>
> Let's see the following instructions:
> --------
> if condition_A:
> instruction_1
> instruction_2
> if condition_B:
> instruction_3
> instruction_4
> instruction_5
> else:
> instruction_6
> --------
>
> * How to make Pythom understand that instruction_4 is a part of condition_B
> if-clause but not a direct instruction of condition_A if-clause? And how
> to make Python understand that instruction_5 is outside of condition_B
> if-clause? Just by the number of white spaces in front of every
> instruction??
>
> * How to make Python understand that "else" belongs to the first
> condition_A if-clause, not to the immediate condition_B if-clause?
>
> * Suppose I put four white spaces in front of instruction_1, and then "tab
> key" in front of instruction_2, would this break things? I ask so because
> most intelligent text editors would insert automatically a tab in place of
> 4 white spaces after we press Enter on a line with 4 leading white spaces.
>
> * Do I really need to keep the consistency of 4 white spaces? Not one more
> or one less?
>
yes. you can use 1 or 2 or any number of spaces, but do spacing
consistently. 4 is recommended. Don't mix tabs and spaces
>
> Thanks in advance.
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
--
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
More information about the Tutor
mailing list