Reputation: 561
I need to repeat in range with itertools.product
with this code:
minLength=InputInt(" Please Enter the Min Length of Your Word : ")
maxLength=InputInt(" Please Enter the Max Length of Your Word : ")
characters=input(" Please Enter the Character of Your Word : ")
res = itertools.product(characters, repeat=range(minLength,maxLength))
for i in res:
print(' Password Created : ',''.join(i), end='\r',flush=True)
but when I use this code repeat=range(minLength,maxLength)
it shows me this error:
res = itertools.product(characters, repeat=range(minLength,maxLength)) TypeError: 'range' object cannot be interpreted as an integer
What's the problem? How can I solve this problem?
Upvotes: 2
Views: 503
Reputation: 71580
You can't do that, use:
res = [x for i in range(minLength,maxLength) for x in itertools.product(characters, repeat=i)]
Upvotes: 3