Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Text Cache | Closure
Mastering Python: Closures and Decorators
course content

Зміст курсу

Mastering Python: Closures and Decorators

Mastering Python: Closures and Decorators

1. Scopes
2. Closure
3. Decorators

Challenge: Text Cache

Завдання

Implement the string_cache() function that returns the inner() function that takes the string value and adds it to the enclosed text.

  1. Create the text variable with the value "" (empty string) in the string_cache() function.
  2. The inner() function should take the string argument with the default value "".
  3. Make the text non-local variable changeable inside the inner() function.
  4. If the string argument is not an empty string, add this string to the text non-local variable. After the first string addition, the addition should be with space.
  5. The inner() function should return the text enclosed variable.
  6. The string_cache() should return the inner() function without calling.
  7. Call the string_cache() function and assign the result to the text_cache variable.

Завдання

Implement the string_cache() function that returns the inner() function that takes the string value and adds it to the enclosed text.

  1. Create the text variable with the value "" (empty string) in the string_cache() function.
  2. The inner() function should take the string argument with the default value "".
  3. Make the text non-local variable changeable inside the inner() function.
  4. If the string argument is not an empty string, add this string to the text non-local variable. After the first string addition, the addition should be with space.
  5. The inner() function should return the text enclosed variable.
  6. The string_cache() should return the inner() function without calling.
  7. Call the string_cache() function and assign the result to the text_cache variable.

Все було зрозуміло?

Секція 2. Розділ 4
toggle bottom row

Challenge: Text Cache

Завдання

Implement the string_cache() function that returns the inner() function that takes the string value and adds it to the enclosed text.

  1. Create the text variable with the value "" (empty string) in the string_cache() function.
  2. The inner() function should take the string argument with the default value "".
  3. Make the text non-local variable changeable inside the inner() function.
  4. If the string argument is not an empty string, add this string to the text non-local variable. After the first string addition, the addition should be with space.
  5. The inner() function should return the text enclosed variable.
  6. The string_cache() should return the inner() function without calling.
  7. Call the string_cache() function and assign the result to the text_cache variable.

Завдання

Implement the string_cache() function that returns the inner() function that takes the string value and adds it to the enclosed text.

  1. Create the text variable with the value "" (empty string) in the string_cache() function.
  2. The inner() function should take the string argument with the default value "".
  3. Make the text non-local variable changeable inside the inner() function.
  4. If the string argument is not an empty string, add this string to the text non-local variable. After the first string addition, the addition should be with space.
  5. The inner() function should return the text enclosed variable.
  6. The string_cache() should return the inner() function without calling.
  7. Call the string_cache() function and assign the result to the text_cache variable.

Все було зрозуміло?

Секція 2. Розділ 4
toggle bottom row

Challenge: Text Cache

Завдання

Implement the string_cache() function that returns the inner() function that takes the string value and adds it to the enclosed text.

  1. Create the text variable with the value "" (empty string) in the string_cache() function.
  2. The inner() function should take the string argument with the default value "".
  3. Make the text non-local variable changeable inside the inner() function.
  4. If the string argument is not an empty string, add this string to the text non-local variable. After the first string addition, the addition should be with space.
  5. The inner() function should return the text enclosed variable.
  6. The string_cache() should return the inner() function without calling.
  7. Call the string_cache() function and assign the result to the text_cache variable.

Завдання

Implement the string_cache() function that returns the inner() function that takes the string value and adds it to the enclosed text.

  1. Create the text variable with the value "" (empty string) in the string_cache() function.
  2. The inner() function should take the string argument with the default value "".
  3. Make the text non-local variable changeable inside the inner() function.
  4. If the string argument is not an empty string, add this string to the text non-local variable. After the first string addition, the addition should be with space.
  5. The inner() function should return the text enclosed variable.
  6. The string_cache() should return the inner() function without calling.
  7. Call the string_cache() function and assign the result to the text_cache variable.

Все було зрозуміло?

Завдання

Implement the string_cache() function that returns the inner() function that takes the string value and adds it to the enclosed text.

  1. Create the text variable with the value "" (empty string) in the string_cache() function.
  2. The inner() function should take the string argument with the default value "".
  3. Make the text non-local variable changeable inside the inner() function.
  4. If the string argument is not an empty string, add this string to the text non-local variable. After the first string addition, the addition should be with space.
  5. The inner() function should return the text enclosed variable.
  6. The string_cache() should return the inner() function without calling.
  7. Call the string_cache() function and assign the result to the text_cache variable.

Секція 2. Розділ 4
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt