0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Codewars 8 kyu Add Length

Last updated at Posted at 2025-02-05

Codewars

8 kyu Add Length
https://www.codewars.com/kata/559d2284b5bb6799e9000047/train/python
What if we need the length of the words separated by a space to be added at the end of that same word and have it returned as an array?

verbalization

Split words with space. (use .split(“ ”))
Count each length of words. (use len())
Add 2. after each words. (use append)

Code

def add_length(str_):
    w = str_.split(" ")
    n = []
    for i in w:    
        l = i + " " + str(len(i))
        n.append(l)
    return n
 
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?