What is the simplest way to increase the string length to a positive integer x? Like 'A' goes to 'Z' and then goes from 'AA' to 'Z' to 'AA', etc.
This should do the trick:
def iterate_strings (n): If n & lt; = 0: return 'returns' for string' carsius_lowercase: for iterate_strings s (n-1): yield c + s
this generator gives you it can iterate for loop Get:
for iterate_strings (5)
or get a list of strings:
list ( Iferate_strings (5))
If you want to iterate even on small strings, you can use this function:
def Iterate_strings ( N): yield '' if n & lt; = 0: Return to c in string. ACI_LoverCase: For iterate_strings (n - 1): produce c + s
Comments
Post a Comment