Concatenate and Repeat Lists

Easy ⏱ 8 min 79% acceptance ★★★★☆ 4.3
Write combine_and_repeat(a, b, times) that returns the concatenation of lists a and b (using +), repeated times times as a whole (using *). For example, if a + b gives [1, 2] and times is 2, the result is [1, 2, 1, 2].

Examples

Example 1
Input
a = [1], b = [2], times = 3
Output
[1, 2, 1, 2, 1, 2]
Explanation

a + b = [1, 2], then that whole sequence repeats 3 times.

Constraints

  • 0 <= times <= 100

Topics

ListsOperators

Companies

TCSInfosys

Hints

Hint 1

(a + b) * times combines concatenation and repetition.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.