In: Computer Science

def permutations(digits):
def permutationsHelper(digits):
if len(digits) == 1:
return [str(digits[0])]
c = str(digits[0])
perms = permutationsHelper(digits[1:])
result = []
for p in perms:
for i in range(len(p) + 1):
x = p[:i] + c + p[i:]
result.append(x)
return result + perms
result = permutationsHelper(digits)
result = [x for x in result if 3 <= len(x) <= 7]
return result
print(permutations([0, 1, 2, 5, 4]))
************************************************** Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.
Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.