-2
final=list(product(char1,char1,char1,char1,char1,char1,char1,char1,char1,char1))

Let’s say the number of char1 in the product function depends on an input. For example, there will be 5 char1 in the product function if the input is 5.

Is it possible to do that?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Amin Wali
  • 1
  • 1
  • Does this answer your question? [Can a variable number of arguments be passed to a function?](https://stackoverflow.com/questions/919680/can-a-variable-number-of-arguments-be-passed-to-a-function) – Gino Mempin Nov 05 '20 at 23:22

3 Answers3

1

Just use parameter destructuring:

count = int(input())
chars = [char1] * count
final = list(product(*chars))
Aplet123
  • 33,825
  • 1
  • 29
  • 55
0

You can just multiply it:

c = [char1]*5
f = list(product(*c))

Replace 5 with the count

Wasif
  • 14,755
  • 3
  • 14
  • 34
0
word=input()
n=int(input())
your_list=[word for i in range(n)]
print(*your_list)

enter image description here