Create a list of 2 variables
list, python, string
Solution
z = [x] + (y if isinstance(y, list) else [y])
Generally I'd avoid having a `y` that could be either a string or a list, though: it seems unnecessary.
Problem
If I have variables `x` and `y`, such that: - `x` is always a string - `y` can either be a string or a list of strings How can I create a list `z == [x, <all elements of y>]`? For instance: ``` x = 'x' y = 'y' # create z assert z == ['x', 'y'] ``` ``` x = 'x' y = ['y', 'y2'] # create z assert z == ['x', 'y', 'y2'] ```