user
Given a string, write a program to find all permutations of that string.
abc

assistant
# Python code to find all permutations of a string  
def permutations(string): 
   
    # If string is empty 
    if len(string) == 0: 
        return [] 

    # If there is only one character in string 
    if len(string) == 1: 
        return [string] 
   
    l = [] # empty list  
   
    # Iterate the input string  
    for i in range(len(string)): 
        m = string[i] 

        # Extracting string here 
        remString = string[:i] + string[i+1:] 

        # Generating all permutations  
        for p in permutations(remString): 
            l.append([m] + p) 
  
    return l 
 
# Driver program  
string = "abc" 
print(permutations(string)) 
# output: [['a', 'b', 'c'], ['b', 'a', 'c'], ['b', 'c', 'a'], ['a', 'c', 'b'], ['c', 'a', 'b'], ['c', 'b', 'a']]