File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,6 +73,19 @@ but it's not possible to create custom keywords. That's why keywords are
7373usually used for "magic" things that would be difficult to do with just
7474functions.
7575
76+ Also note that if statements check the condition once only, so if you
77+ set it to false later the if statement won't notice it.
78+
79+ ``` py
80+ >> > its_raining = True
81+ >> > if its_raining:
82+ ... its_raining = False
83+ ... print (" It's not raining, but this runs anyway." )
84+ ...
85+ It' s not raining, but this runs anyway.
86+ >> >
87+ ```
88+
7689## Storing code in files
7790
7891At this point it's easier to put your code into a file and use it
@@ -167,7 +180,20 @@ else:
167180 print (" It's not raining." )
168181```
169182
170- By combining that with the input function we can make a program that
183+ The else part simply runs when the if statement doesn't run. It doesn't
184+ check the condition again.
185+
186+ ``` py
187+ >> > its_raining = True
188+ >> > if its_raining:
189+ ... its_raining = False
190+ ... else :
191+ ... print (" It's not raining, but this still doesn't run." )
192+ ...
193+ >> >
194+ ```
195+
196+ By combining ` else ` with the input function we can make a program that
171197asks for a password and checks if it's correct.
172198
173199``` py
You can’t perform that action at this time.
0 commit comments