2
I am working on this code that generates sequences with all the possibilities of the characters entered(your_list)
your_list = 'abcdefghijklmnopqrstuvwxyz'
complete_list = []
for current in range(10):
a = [i for i in your_list]
for y in range(current):
a = [x+i for i in your_list for x in a]
complete_list = complete_list+a
print (complete_list)
I’m finding the error highlighted below, but I don’t know how to solve this problem
"C:\Users\admin\PycharmProjects\markestrat\venv\Scripts\python.exe" "C:/Users/admin/PycharmProjects/markestrat/venv/brutef.py"
Traceback (most recent call last):
File "C:/Users/admin/PycharmProjects/markestrat/venv/brutef.py", line 65, in <module>
a = [x+i for i in your_list for x in a]
File "C:/Users/admin/PycharmProjects/markestrat/venv/brutef.py", line 65, in <listcomp>
a = [x+i for i in your_list for x in a]
MemoryError
Does anyone know how to solve this problem?
What would be the intended result? All combinations between letters of the alphabet? What sizes? Replacement or not? Does order matter? That is to say,
ab
andba
would be equivalent or not?– Woss
[ab] and [ba] would not be equivalent, for now I’m just testing, so the size does not make much difference now, a 4 or 5 characters is already good, but the problem is when I do something with much more characters, it accuses Memory Error, as in this example of 10 characters, but with 4 or 5, the program works normally and quickly, from the sixth character it accuses error
– Luis Fernando Garcia
Yes, because you keep all combinations in a list. This is not necessary and already ahead for you to study generators.
– Woss