File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ Don't give up. Difficult roads **often** lead to beautiful destinations.
6565 3.11 [Generators](#3.11)
6666 3.11.1 [Generator Function](#3.11.1)
6767 3.11.2 [Generator Expression](#3.11.2)
68- 3.11.3[Generator Exercices .](#3.11.3)
68+ 3.11.3 [Generator Exercises .](#3.11.3)
6969 3.12 [Input](#3.12)
7070 3.13 [Exceptions](#3.13)
7171
@@ -2051,7 +2051,7 @@ StopIteration
20512051128
20522052```
20532053
2054- # ## 3.11.3 Generator Exercices . <a name="3.11.3"></a><h5>[Go To TOC](#TOC).</h5>
2054+ # ## 3.11.3 Generator Exercises . <a name="3.11.3"></a><h5>[Go To TOC](#TOC).</h5>
20552055
20562056```python
20572057>> > def factorial():
@@ -2126,8 +2126,18 @@ StopIteration
21262126Using the built- in `input ()` method, you can get information from the user. It has an optional parameter `prompt` which prints a string on the screen.
21272127
21282128```python
2129- >> > n = eval (input (" please give me a number and press <return> : " )) # eval converts the input to int .
2129+ >> > n = eval (input (" please give me a number and press <return> : " )) # evaluate the input string as code. .
21302130please give me a number and press < return > : 10
2131+ >> > import os
2132+ >> > n = eval (input ())
2133+ os.system(' ls' ) # <----- you can insert a command as a string. So using eval is a security hole.
2134+ ' Chapter_01: The Language Basics.md' Exercises LICENSE README .md
2135+ ' Chapter_02: Functions, File IO, Generators.md' Images Projets
2136+ ```
2137+
2138+ ** Fun Exercises**
2139+
2140+ ```python
21312141>> > for i in range (n):
21322142... print (' ' * ( n - i - 1 ) + ' *' * ( 2 * i + 1 ))
21332143...
You can’t perform that action at this time.
0 commit comments