ubuntu2004
Kernel: Python 3 (system-wide)
Functions IV - functions can call functions
As we've seen a function can be called form inside another function. The following code shows an example we've already seen.
In [0]:
In this example we call the function say_hello() which we have written. Our function calls the inbuilt function print().
But our function can also call another function that we have written.
Look at the following code then run it.
In [0]:
Here we have defined two functions.
The first, add_full_stop(), takes a string as an argument and returns that string with a full stop added.
The second, say_hello(), takes a string as an argument, it calls add_full_stop() with that string included in the sentence "Hello name" (which adds a full stop) and assigns the returned string to the variable sentence.