Hello everyone,
Thank you for your many answers, I looked at what you suggested but that does not seem to be the solution. Some have also given me advice and it will be useful, especially in the rest of my learning, so thank you!
I originally wanted to create my own brute force program to train
Regarding the code, it is true that it is not very clever of me not to put it so here it is below.
I applied Bowlofred's advice to see where the problem is. So I see that the loop continues (and the i += 1 as well). So it's weird because normally the "while" should stop it. Is it the "for" loop blocking this?
list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
word = input("Enter your password : ")
word = [caractere for caractere in word]
chain = ""
i = 0
while i < len(word):
for l in list:
print("i is egal to ", i, " and the length is", len(word))
print("i is egal to ", l, " and the length is", word[i], "\n \n")
print("the complete chain is", chain)
if l == word[i]:
chain += l
if word != chain:
i += 1
print(chain)
[/python]
Output :
Enter your password : def
i is egal to 0 and the length is 3
i is egal to a and the length is d
the complete chain is
i is egal to 0 and the length is 3
i is egal to b and the length is d
the complete chain is
i is egal to 0 and the length is 3
i is egal to c and the length is d
the complete chain is
i is egal to 0 and the length is 3
i is egal to d and the length is d
the complete chain is
i is egal to 1 and the length is 3
i is egal to e and the length is e
the complete chain is d
i is egal to 2 and the length is 3
i is egal to f and the length is f
the complete chain is de
i is egal to 3 and the length is 3
Traceback (most recent call last):
File "C:\Users\KILIAN\Documents\english.py", line 10, in <module>
print("i is egal to ", l, " and the length is", word
, "\n \n")
~~~~^^^
IndexError: list index out of range
---
if word != chain:
i += 1
I added this if so that the iteration is not done on i += 1 when the word is found
---
For the "while" I originally wrote while word =! chain but that didn't work either
If you give me the solution it would of course be great, but if you have the patience to give me my clues, to put me on the path with explanations so that I can fully understand on my own, it would be really incredible!
Thanks.
[i]Incidentally very strange but the only password that does not return an error is "az"