diff options
| author | 2021-04-12 18:00:23 -0400 | |
|---|---|---|
| committer | 2021-04-12 18:00:23 -0400 | |
| commit | 8baee2e1f04df52a87f620a8c004028cecdc9e39 (patch) | |
| tree | 2d0686e461a89c1cf397616e2d142fcf95a1cb78 | |
| parent | Create str-join.md (diff) | |
Be more consistent with word choice.
Changed "method" and "way" to "solution"
| -rw-r--r-- | bot/resources/tags/str-join.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/bot/resources/tags/str-join.md b/bot/resources/tags/str-join.md index e8407ac26..6390db9e5 100644 --- a/bot/resources/tags/str-join.md +++ b/bot/resources/tags/str-join.md @@ -9,15 +9,15 @@ for color in colors: output += color + separator print(output) # Prints 'red, green, blue, yellow, ' ``` -However, this solution is flawed. The separator is still added to the last color, and it is slow. +However, this solution is flawed. The separator is still added to the last element, and it is slow. -The better way is to use `str.join`. +The better solution is to use `str.join`. ```py colors = ['red', 'green', 'blue', 'yellow'] separator = ", " print(separator.join(colors)) # Prints 'red, green, blue, yellow' ``` -This method is much simpler, faster, and solves the problem of the extra separator. An important thing to note is that you can only `str.join` strings. For a list of ints, +This solution is much simpler, faster, and solves the problem of the extra separator. An important thing to note is that you can only `str.join` strings. For a list of ints, you must convert each element to a string before joining. ```py integers = [1, 3, 6, 10, 15] |