From a4df5d49f3b360dda20ba08e5724ab911f193a38 Mon Sep 17 00:00:00 2001 From: BethanyG Date: Thu, 25 Sep 2025 16:15:17 -0700 Subject: [PATCH 1/6] Fixed up code examples for join and added an additional hint. --- .../little-sisters-vocab/.docs/hints.md | 1 + .../.docs/introduction.md | 31 ++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/exercises/concept/little-sisters-vocab/.docs/hints.md b/exercises/concept/little-sisters-vocab/.docs/hints.md index 2e5540805c4..4fc436cf018 100644 --- a/exercises/concept/little-sisters-vocab/.docs/hints.md +++ b/exercises/concept/little-sisters-vocab/.docs/hints.md @@ -16,6 +16,7 @@ There's four activities in the assignment, each with a set of text or words to w - Believe it or not, [`str.join()`][str-join] is all you need here. - Like [`str.split()`][str-split]`, `str.join()` can take an arbitrary-length string, made up of any unicode code points. +- The tests will be feeding your function a `list`. There will be no need to alter this list, provided you use `.join()` correctly. ## 3. Remove a suffix from a word diff --git a/exercises/concept/little-sisters-vocab/.docs/introduction.md b/exercises/concept/little-sisters-vocab/.docs/introduction.md index 7aaea474ee2..6b24b6c9fa6 100644 --- a/exercises/concept/little-sisters-vocab/.docs/introduction.md +++ b/exercises/concept/little-sisters-vocab/.docs/introduction.md @@ -50,7 +50,7 @@ If a `list`, `tuple`, `set` or other collection of individual strings needs to b ```python # str.join() makes a new string from the iterables elements. ->>> chickens = ["hen", "egg", "rooster"] +>>> chickens = ["hen", "egg", "rooster"] #lists are iterable >>> ' '.join(chickens) 'hen egg rooster' @@ -60,8 +60,37 @@ If a `list`, `tuple`, `set` or other collection of individual strings needs to b >>> ' 🌿 '.join(chickens) 'hen 🌿 egg 🌿 rooster' + + +# Any iterable can be used as input. +>>> flowers = ("rose", "daisy", "carnation") #tuples are iterable +>>> '*-*'.join(flowers) +'rose*-*daisy*-*carnation' + +>>> flowers = {"rose", "daisy", "carnation"} #sets are iterable, but output order is not guaranteed. +>>> '*-*'.join(flowers) +'rose*-*carnation*-*daisy' + +>>> phrase = "This is my string" #strings are iterable, but be careful! +>>> '..'.join(phrase) +'T..h..i..s.. ..i..s.. ..m..y.. ..s..t..r..i..n..g' + + +# Separators are inserted **between** elements, but can be any string (including spaces). +# This can be exploited for interesting effects. +>>> under_words = ['under', 'current', 'sea', 'pin', 'dog', 'lay'] +>>> separator = ' ⤴️ under' +>>> separator.join(under_words) +'under ⤴️ undercurrent ⤴️ undersea ⤴️ underpin ⤴️ underdog ⤴️ underlay' + +# The seperator can be composed different ways, as long as the result is a string. +>>> upper_words = ['upper', 'crust', 'case', 'classmen', 'most', 'cut'] +>>> separator = ' 🌟 ' + upper_words[0] +>>> separator.join(upper_words) + 'upper 🌟 uppercrust 🌟 uppercase 🌟 upperclassmen 🌟 uppermost 🌟 uppercut' ``` + Code points within a `str` can be referenced by `0-based index` number from the left: From 2d33f9c7f733fc56bb8c50f3b5d07f7cad3b2b07 Mon Sep 17 00:00:00 2001 From: BethanyG Date: Fri, 26 Sep 2025 06:38:49 -0700 Subject: [PATCH 2/6] Touched up hints phrasing, added no loop directive to instructions, and added additional examples to concept about. --- concepts/strings/about.md | 36 +++++++++++++++++-- .../little-sisters-vocab/.docs/hints.md | 8 +++-- .../.docs/instructions.md | 3 ++ .../.docs/introduction.md | 3 -- 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/concepts/strings/about.md b/concepts/strings/about.md index 0107f6e70f0..7d28e808b07 100644 --- a/concepts/strings/about.md +++ b/concepts/strings/about.md @@ -9,7 +9,7 @@ The Python docs also provide a very detailed [unicode HOWTO][unicode how-to] tha Strings implement all [common sequence operations][common sequence operations] and can be iterated through using `for item in ` or `for index, item in enumerate()` syntax. Individual code points (_strings of length 1_) can be referenced by `0-based index` number from the left, or `-1-based index` number from the right. -Strings can be concatenated with `+`, or via `.join()`, split via `.split()`, and offer multiple formatting and assembly options. +Strings can be concatenated with `+`, or via `.join()`, split via `.split()`, and offer multiple formatting, assembly, and templating options. A `str` literal can be declared via single `'` or double `"` quotes. The escape `\` character is available as needed. @@ -173,7 +173,7 @@ If a `list`, `tuple`, `set` or other collection of individual strings needs to b ```python # str.join() makes a new string from the iterables elements. ->>> chickens = ["hen", "egg", "rooster"] +>>> chickens = ["hen", "egg", "rooster"] #lists are iterable >>> ' '.join(chickens) 'hen egg rooster' @@ -183,6 +183,34 @@ If a `list`, `tuple`, `set` or other collection of individual strings needs to b >>> ' 🌿 '.join(chickens) 'hen 🌿 egg 🌿 rooster' + + +# Any iterable can be used as input. +>>> flowers = ("rose", "daisy", "carnation") #tuples are iterable +>>> '*-*'.join(flowers) +'rose*-*daisy*-*carnation' + +>>> flowers = {"rose", "daisy", "carnation"} #sets are iterable, but output order is not guaranteed. +>>> '*-*'.join(flowers) +'rose*-*carnation*-*daisy' + +>>> phrase = "This is my string" #strings are iterable, but be careful! +>>> '..'.join(phrase) +'T..h..i..s.. ..i..s.. ..m..y.. ..s..t..r..i..n..g' + + +# Separators are inserted **between** elements, but can be any string (including spaces). +# This can be exploited for interesting effects. +>>> under_words = ['under', 'current', 'sea', 'pin', 'dog', 'lay'] +>>> separator = ' ⤴️ under' #note the leading space, but no trailing space. +>>> separator.join(under_words) +'under ⤴️ undercurrent ⤴️ undersea ⤴️ underpin ⤴️ underdog ⤴️ underlay' + +# The seperator can be composed different ways, as long as the result is a string. +>>> upper_words = ['upper', 'crust', 'case', 'classmen', 'most', 'cut'] +>>> separator = ' 🌟 ' + upper_words[0] #this becomes one string, similar to ' ⤴️ under'. +>>> separator.join(upper_words) + 'upper 🌟 uppercrust 🌟 uppercase 🌟 upperclassmen 🌟 uppermost 🌟 uppercut' ``` Strings support all [common sequence operations][common sequence operations]. @@ -194,7 +222,9 @@ Indexes _with_ items can be iterated through in a loop via `for index, item in e >>> exercise = 'လေ့ကျင့်' -# Note that there are more code points than perceived glyphs or characters +# Note that there are more code points than perceived glyphs or characters. +# Care should be used when iterating over languages that use +# combining characters, or when dealing with emoji. >>> for code_point in exercise: ... print(code_point) ... diff --git a/exercises/concept/little-sisters-vocab/.docs/hints.md b/exercises/concept/little-sisters-vocab/.docs/hints.md index 4fc436cf018..0be143a7f66 100644 --- a/exercises/concept/little-sisters-vocab/.docs/hints.md +++ b/exercises/concept/little-sisters-vocab/.docs/hints.md @@ -14,9 +14,11 @@ There's four activities in the assignment, each with a set of text or words to w ## 2. Add prefixes to word groups -- Believe it or not, [`str.join()`][str-join] is all you need here. -- Like [`str.split()`][str-split]`, `str.join()` can take an arbitrary-length string, made up of any unicode code points. -- The tests will be feeding your function a `list`. There will be no need to alter this list, provided you use `.join()` correctly. +- Believe it or not, [`str.join()`][str-join] is all you need here. **A loop is not required**. +- The tests will be feeding your function a `list`. There will be no need to alter this `list` if you can figure out a good delimiter string. +- Remember that delimiter strings go between elements and "glue" them together into a single string. Delimiters are inserted _without_ space, although you can include space characters within them. +- Like [`str.split()`][str-split], `str.join()` can process an arbitrary-length string, made up of any unicode code points. _Unlike_ `str.split()`, it can also process arbitrary-length iterables like `list`, `tuple`, and `set`. + ## 3. Remove a suffix from a word diff --git a/exercises/concept/little-sisters-vocab/.docs/instructions.md b/exercises/concept/little-sisters-vocab/.docs/instructions.md index 2658bb980a4..991845a7043 100644 --- a/exercises/concept/little-sisters-vocab/.docs/instructions.md +++ b/exercises/concept/little-sisters-vocab/.docs/instructions.md @@ -40,6 +40,9 @@ Implement the `make_word_groups()` function that takes a `vocab_wor `[, , .... ]`, and returns a string with the prefix applied to each word that looks like: `' :: :: :: '`. +Creating a `for` or `while` loop to process the input is not needed here. +Think carefully about which string methods (and delimiters) you could use instead. + ```python >>> make_word_groups(['en', 'close', 'joy', 'lighten']) diff --git a/exercises/concept/little-sisters-vocab/.docs/introduction.md b/exercises/concept/little-sisters-vocab/.docs/introduction.md index 6b24b6c9fa6..ed922c5f268 100644 --- a/exercises/concept/little-sisters-vocab/.docs/introduction.md +++ b/exercises/concept/little-sisters-vocab/.docs/introduction.md @@ -90,7 +90,6 @@ If a `list`, `tuple`, `set` or other collection of individual strings needs to b 'upper 🌟 uppercrust 🌟 uppercase 🌟 upperclassmen 🌟 uppermost 🌟 uppercut' ``` - Code points within a `str` can be referenced by `0-based index` number from the left: @@ -124,7 +123,6 @@ creative = '창의적인' ``` - There is no separate “character” or "rune" type in Python, so indexing a string produces a new `str` of length 1: @@ -198,7 +196,6 @@ Strings can also be broken into smaller strings via [`.split()`] ['feline', 'four-footed', 'ferocious', 'furry'] ``` - Separators for `.split()` can be more than one character. The **whole string** is used for split matching. From 92378b1d253de87681c5663f5b7d501a548e696b Mon Sep 17 00:00:00 2001 From: BethanyG Date: Fri, 26 Sep 2025 06:48:38 -0700 Subject: [PATCH 3/6] Typo correction. --- concepts/strings/about.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/concepts/strings/about.md b/concepts/strings/about.md index 7d28e808b07..8ae4f177d53 100644 --- a/concepts/strings/about.md +++ b/concepts/strings/about.md @@ -168,7 +168,7 @@ sentence = word + " " + "means" + " " + number + " in " + language + "." "дев'ять means nine in Ukrainian." ``` -If a `list`, `tuple`, `set` or other collection of individual strings needs to be combined into a single `str`, [`.join()`][str-join], is a better option: +If a `list`, `tuple`, `set` or other collection of individual strings needs to be combined into a single `str`, [`.join()`][str-join] is a better option: ```python From 7786d22cee0b56da18746c70b58f7369ffbadd11 Mon Sep 17 00:00:00 2001 From: BethanyG Date: Fri, 26 Sep 2025 07:00:25 -0700 Subject: [PATCH 4/6] Corrected separator misspelling. --- concepts/strings/about.md | 2 +- exercises/concept/little-sisters-vocab/.docs/introduction.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/concepts/strings/about.md b/concepts/strings/about.md index 8ae4f177d53..aaaf2e2fb70 100644 --- a/concepts/strings/about.md +++ b/concepts/strings/about.md @@ -206,7 +206,7 @@ If a `list`, `tuple`, `set` or other collection of individual strings needs to b >>> separator.join(under_words) 'under ⤴️ undercurrent ⤴️ undersea ⤴️ underpin ⤴️ underdog ⤴️ underlay' -# The seperator can be composed different ways, as long as the result is a string. +# The separator can be composed different ways, as long as the result is a string. >>> upper_words = ['upper', 'crust', 'case', 'classmen', 'most', 'cut'] >>> separator = ' 🌟 ' + upper_words[0] #this becomes one string, similar to ' ⤴️ under'. >>> separator.join(upper_words) diff --git a/exercises/concept/little-sisters-vocab/.docs/introduction.md b/exercises/concept/little-sisters-vocab/.docs/introduction.md index ed922c5f268..aec7eea211e 100644 --- a/exercises/concept/little-sisters-vocab/.docs/introduction.md +++ b/exercises/concept/little-sisters-vocab/.docs/introduction.md @@ -83,7 +83,7 @@ If a `list`, `tuple`, `set` or other collection of individual strings needs to b >>> separator.join(under_words) 'under ⤴️ undercurrent ⤴️ undersea ⤴️ underpin ⤴️ underdog ⤴️ underlay' -# The seperator can be composed different ways, as long as the result is a string. +# The separator can be composed different ways, as long as the result is a string. >>> upper_words = ['upper', 'crust', 'case', 'classmen', 'most', 'cut'] >>> separator = ' 🌟 ' + upper_words[0] >>> separator.join(upper_words) From 50cc8f3f81b48781e9445d79900bcdc320df1da9 Mon Sep 17 00:00:00 2001 From: BethanyG Date: Fri, 26 Sep 2025 09:38:44 -0700 Subject: [PATCH 5/6] Cleaned up in-line comments per PR review. --- concepts/strings/about.md | 12 ++++++------ .../little-sisters-vocab/.docs/introduction.md | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/concepts/strings/about.md b/concepts/strings/about.md index aaaf2e2fb70..39704de25db 100644 --- a/concepts/strings/about.md +++ b/concepts/strings/about.md @@ -173,7 +173,7 @@ If a `list`, `tuple`, `set` or other collection of individual strings needs to b ```python # str.join() makes a new string from the iterables elements. ->>> chickens = ["hen", "egg", "rooster"] #lists are iterable +>>> chickens = ["hen", "egg", "rooster"] # Lists are iterable. >>> ' '.join(chickens) 'hen egg rooster' @@ -186,15 +186,15 @@ If a `list`, `tuple`, `set` or other collection of individual strings needs to b # Any iterable can be used as input. ->>> flowers = ("rose", "daisy", "carnation") #tuples are iterable +>>> flowers = ("rose", "daisy", "carnation") # Tuples are iterable. >>> '*-*'.join(flowers) 'rose*-*daisy*-*carnation' ->>> flowers = {"rose", "daisy", "carnation"} #sets are iterable, but output order is not guaranteed. +>>> flowers = {"rose", "daisy", "carnation"} # Sets are iterable, but output order is not guaranteed. >>> '*-*'.join(flowers) 'rose*-*carnation*-*daisy' ->>> phrase = "This is my string" #strings are iterable, but be careful! +>>> phrase = "This is my string" # Strings are iterable, but be careful! >>> '..'.join(phrase) 'T..h..i..s.. ..i..s.. ..m..y.. ..s..t..r..i..n..g' @@ -202,13 +202,13 @@ If a `list`, `tuple`, `set` or other collection of individual strings needs to b # Separators are inserted **between** elements, but can be any string (including spaces). # This can be exploited for interesting effects. >>> under_words = ['under', 'current', 'sea', 'pin', 'dog', 'lay'] ->>> separator = ' ⤴️ under' #note the leading space, but no trailing space. +>>> separator = ' ⤴️ under' # note the leading space, but no trailing space. >>> separator.join(under_words) 'under ⤴️ undercurrent ⤴️ undersea ⤴️ underpin ⤴️ underdog ⤴️ underlay' # The separator can be composed different ways, as long as the result is a string. >>> upper_words = ['upper', 'crust', 'case', 'classmen', 'most', 'cut'] ->>> separator = ' 🌟 ' + upper_words[0] #this becomes one string, similar to ' ⤴️ under'. +>>> separator = ' 🌟 ' + upper_words[0] # this becomes one string, similar to ' ⤴️ under'. >>> separator.join(upper_words) 'upper 🌟 uppercrust 🌟 uppercase 🌟 upperclassmen 🌟 uppermost 🌟 uppercut' ``` diff --git a/exercises/concept/little-sisters-vocab/.docs/introduction.md b/exercises/concept/little-sisters-vocab/.docs/introduction.md index aec7eea211e..3b7ee76b275 100644 --- a/exercises/concept/little-sisters-vocab/.docs/introduction.md +++ b/exercises/concept/little-sisters-vocab/.docs/introduction.md @@ -50,7 +50,7 @@ If a `list`, `tuple`, `set` or other collection of individual strings needs to b ```python # str.join() makes a new string from the iterables elements. ->>> chickens = ["hen", "egg", "rooster"] #lists are iterable +>>> chickens = ["hen", "egg", "rooster"] # Lists are iterable. >>> ' '.join(chickens) 'hen egg rooster' @@ -63,15 +63,15 @@ If a `list`, `tuple`, `set` or other collection of individual strings needs to b # Any iterable can be used as input. ->>> flowers = ("rose", "daisy", "carnation") #tuples are iterable +>>> flowers = ("rose", "daisy", "carnation") # Tuples are iterable. >>> '*-*'.join(flowers) 'rose*-*daisy*-*carnation' ->>> flowers = {"rose", "daisy", "carnation"} #sets are iterable, but output order is not guaranteed. +>>> flowers = {"rose", "daisy", "carnation"} # Sets are iterable, but output order is not guaranteed. >>> '*-*'.join(flowers) 'rose*-*carnation*-*daisy' ->>> phrase = "This is my string" #strings are iterable, but be careful! +>>> phrase = "This is my string" # Strings are iterable, but be careful! >>> '..'.join(phrase) 'T..h..i..s.. ..i..s.. ..m..y.. ..s..t..r..i..n..g' From 5d37b60256abef0dd9e9c41cb1f3d19b5ca2ac7a Mon Sep 17 00:00:00 2001 From: BethanyG Date: Fri, 26 Sep 2025 09:42:50 -0700 Subject: [PATCH 6/6] Fixed capitalization on inline comments in last join example. --- concepts/strings/about.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/concepts/strings/about.md b/concepts/strings/about.md index 39704de25db..064c4c11bcb 100644 --- a/concepts/strings/about.md +++ b/concepts/strings/about.md @@ -202,13 +202,13 @@ If a `list`, `tuple`, `set` or other collection of individual strings needs to b # Separators are inserted **between** elements, but can be any string (including spaces). # This can be exploited for interesting effects. >>> under_words = ['under', 'current', 'sea', 'pin', 'dog', 'lay'] ->>> separator = ' ⤴️ under' # note the leading space, but no trailing space. +>>> separator = ' ⤴️ under' # Note the leading space, but no trailing space. >>> separator.join(under_words) 'under ⤴️ undercurrent ⤴️ undersea ⤴️ underpin ⤴️ underdog ⤴️ underlay' # The separator can be composed different ways, as long as the result is a string. >>> upper_words = ['upper', 'crust', 'case', 'classmen', 'most', 'cut'] ->>> separator = ' 🌟 ' + upper_words[0] # this becomes one string, similar to ' ⤴️ under'. +>>> separator = ' 🌟 ' + upper_words[0] # This becomes one string, similar to ' ⤴️ under'. >>> separator.join(upper_words) 'upper 🌟 uppercrust 🌟 uppercase 🌟 upperclassmen 🌟 uppermost 🌟 uppercut' ```