Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

find all subsequences of a list python

# from https://www.askpython.com/python/examples/possible-subsequences-subsets

def get_all_subsequence(n, output, i):
    if (i == len(n)):
        if (len(output) != 0):
            print(output)
    else:
        # exclude first character
        get_all_subsequence(n, output, i + 1)

        # include first character
        output += n[i]
        get_all_subsequence(n, output, i + 1)
    return


n = input()
get_all_subsequence(n, "", 0)
print(n[0])
 
PREVIOUS NEXT
Tagged: #find #subsequences #list #python
ADD COMMENT
Topic
Name
2+8 =