File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed 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
73
73
usually used for "magic" things that would be difficult to do with just
74
74
functions.
75
75
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
+
76
89
## Storing code in files
77
90
78
91
At this point it's easier to put your code into a file and use it
@@ -167,7 +180,20 @@ else:
167
180
print (" It's not raining." )
168
181
```
169
182
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
171
197
asks for a password and checks if it's correct.
172
198
173
199
``` py
You can’t perform that action at this time.
0 commit comments