June 2021
Beginner
344 pages
8h 9m
English
You’re frequently going to be asking the user for their name in this chapter. Whenever you have commonly used code, it’s a good idea to move it into a function. This has two advantages: you don’t keep typing the same code, and a single call to what_is_your_name() is less disruptive of the overall flow of your function, which lets you concentrate on the important parts. This is a form of abstraction: you replace detailed code with a function call and move the detail into a function.
When Should I Use a Function? | |
|---|---|
|
|
Try to use a function when you are typing the same code repeatedly. This is called the DRY principle: Do ... |
Read now
Unlock full access