DNPotapov / Codewars-katas-

0 stars 0 forks source link

Substring fun (7 kyu) #5

Open DNPotapov opened 1 year ago

DNPotapov commented 1 year ago
def nth_char(words):
    result = ""
    i = 0
    for item in words:
        result += item[i]
        i += 1
    return result
DNPotapov commented 1 year ago

Complete the function that takes an array of words.

You must concatenate the nth letter from each word to construct a new word which should be returned as a string, where n is the position of the word in the list.

For example:

["yoda", "best", "has"] --> "yes" ^ ^ ^ n=0 n=1 n=2 Note: Test cases contain valid input only - i.e. a string array or an empty array; and each word will have enough letters.

DNPotapov commented 1 year ago

https://www.codewars.com/kata/565b112d09c1adfdd500019c