Horje
how to print all combinations of a string in python Code Example
how to print all combinations of a string in python
test_str = "abc"
res = [test_str[i: j] for i in range(len(test_str)) 
          for j in range(i + 1, len(test_str) + 1)]
print(res)#['a', 'ab', 'abc', 'b', 'bc', 'c']
python print combinations of string
import itertools
 
if __name__ == '__main__':
 
    nums = list("ABC")
    permutations = list(itertools.permutations(nums))
 
    # Output: ['ABC', 'ACB', 'BAC', 'BCA', 'CAB', 'CBA']
    print([''.join(permutation) for permutation in permutations])




Python

Related
python - exclude rowin data frame based on value Code Example python - exclude rowin data frame based on value Code Example
if none in column remove row Code Example if none in column remove row Code Example
how to read from a file into a list in python Code Example how to read from a file into a list in python Code Example
python create file if not exists Code Example python create file if not exists Code Example
ros python publisher Code Example ros python publisher Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8