I'm writing a function to append an input to a list. I want it so that when you input
>>> number, factor = input().split() 280 2 >>> [number]*int(factor) ['280', '280']
Remember that concatenating a list with itself with the * operator can have unexpected results if your list contains mutable elements - but in your case it's fine.
Solution that can handle inputs without a factor:
>>> def multiply_input(): ... *head, tail = input().split() ... return head*int(tail) if head else [tail] ... >>> multiply_input() 280 3 ['280', '280', '280'] >>> multiply_input() 280 ['280']
Add error checking as needed (for example for empty inputs) depending on your use case.