Change language

# Python | Print all string combinations from given numbers

|

Examples :

`  Input:  191  Output:  aia sa  Explanation:  The Possible String digit are 1, 9 and 1 -" aia 19 and 1 -" sa  Input:  1119  Output:  aaai aas aki kai ks `

Suitable :

• Get a string and find the entire list of combinations in the specified order.
• Find a list whose integers are in the range 0 to 25.
• Convert integers to alphabets.
• Sort this in lexicographic order.

 ` # Python program to print the entire line ` ` # combination of the given numbers `   ` # Function for finding a combination ` ` def ` ` Number_to_String (String): `   ` # line length ` ` ` ` length ` ` = ` ` len ` ` (String) `   ` ` ` # temporary lists ` ` temp1 ` ` = ` ` [] ` ` temp2 ` ` = ` ` [] `   ` ` ` # alphabet sequence ` ` alphabet ` ` = ` ` "abcdefghijklmnopqrstuvwxyz" `   ` # Variable power ` ` ` ` power ` ` = ` ` 2 ` ` * ` ` * ` ` (length ` ` - ` ` 1 ` `) `   ` for ` ` i ` ` in ` ` range ` ` (` ` 0 ` `, power): `   ` # timeline ` ` sub ` ` = ` `" "` ` Shift ` ` = ` ` i ` ` x ` ` = ` ` 0 ` ` sub ` ` + ` ` = ` ` String [x] ` ` x ` ` + ` ` = ` ` 1 ` ` for ` ` j ` ` in ` ` range ` ` (length ` ` - ` ` 1 ` `): ` ` if ` ` Shift & amp; ` ` 1 : `` sub + = "" Shift = Shift"" 1 sub + = String [x]   x + = 1   temp1.append ( list ( map ( int , sub.split ())))   # Integer to string for index in temp1:  substring = "" for j in index: if j"  0 and j " = 26 :    substring + = alphabet [j - 1 ] if len (substring) = = len (index): temp2.append (substring)   # lexicographic order sorting   print ( * sorted (temp2), sep = "" )   Driver code Number_to_String ( "191" ) Number_to_String ( "1991" ) Number_to_String ( "1532" ) Number_to_String ( "1191" ) `

Output:

` aia sa aiia sia aecb ocb aaia asa kia `

## Shop

Learn programming in R: courses

\$

Best Python online courses for 2022

\$

Best laptop for Fortnite

\$

Best laptop for Excel

\$

Best laptop for Solidworks

\$

Best laptop for Roblox

\$

Best computer for crypto mining

\$

Best laptop for Sims 4

\$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

NUMPYNUMPY

How to specify multiple return types using type-hints

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

NUMPYNUMPY

glob exclude pattern

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

NUMPYNUMPY

Python CSV error: line contains NULL byte

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

## Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically