I have a code for finding the possible combinations of a given string in the list. But facing an issue with leading zero getting error like SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers . How to overcome this issue as I wanted to pass values with leading zeros(Cannot edit the values manually all the time). Below is my code
def permute_string(str):
if len(str) == 0:
return ['']
prev_list = permute_string(str[1:len(str)])
next_list = []
for i in range(0,len(prev_list)):
for j in range(0,len(str)):
new_str = prev_list[i][0:j]+str[0]+prev_list[i][j:len(str)-1]
if new_str not in next_list:
next_list.append(new_str)
return next_list
list = [129, 831 ,014]
length = len(list)
i = 0
# Iterating using while loop
while i < length:
a = list[i]
print(permute_string(str(a)))
i += 1;