-3
__author__ = 'Mark'
import itertools

def power(num, x=1):
  result = 1;
  for x in range(x):
    result = result * num
  return result
print power(4,7)

count = 0
for subset in itertools.product('0123456', repeat = 4):
     print(subset)
     count +=1
     print count

I need to enumerate all possible permutation of a 4-digit number using 0-6 only with repetition.

3
  • 2
    where is your attempts? Commented Dec 11, 2015 at 8:03
  • 1
    @user5667787 Have a look at the itertools module in python - docs.python.org/2/library/itertools.html & try to solve the question. If you are still facing issues then you can reach out. Without an attempt to solve the problem the SO community would not help! Commented Dec 11, 2015 at 8:22
  • Possible duplicate of Python permutation Commented Dec 11, 2015 at 9:07

1 Answer 1

0

Take a look at product, permutations, combinations, combinations_wit_replacement functions from itertools.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.