I'm attempting to replicate the attached piece of C# code in Python, but unfortunately I know a lot less about Python than I do with the former. The code essentially generates a list of 2 character/digit values e.g. aa, ab, ac, ad, etc. It includes combinations of A-Z, a-z, and 0-9.
I've looked into django.utils.crypto module, but that creates a randomised output, and the output from my C# code gives the exact amount of combinations when run. This is what I tried with Django's module:
get_random_string(length=2,
allowed_chars=u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
Other options I tried do something similar, so I'm at a bit of a loss. I know the basics of Python, but unfortunately I haven't found enough to be able to replicate my C# code in Python. The C# code:
var alpha =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var q = alpha.Select(x => x.ToString());
int size = 2;
for (int i = 0; i < size - 1; i++)
q = q.SelectMany(x => alphabet, (x, y) => x + y);
foreach (var item in q)
Console.WriteLine(item);
Converted into python, the function should generate about 62^2 combinations of the values in 2 digit integers.