Solutions for Little Sister’s Vocabulary Exercise

What approach is better?
Something like this:

def make_word_groups(vocab_words):
prefix = vocab_words[0]
words = vocab_words[1:]
word_groups = [prefix] + [(prefix + word) for word in words]
return " :: ".join(word_groups)

Or something like this in just one line?

def make_word_groups(vocab_words):
return " :: ".join([vocab_words[0]] + [(vocab_words[0] + word) for
word in vocab_words[1:]])

That’s a wonderful question to ask a mentor on a code review! I would encourage you to use the Code Review button on the exercise to discuss that with a mentor.

3 Likes