0

What's wrong with this python code?

<p>import itertools import time Alphabet = ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_.") Password = input("What is your password?\n"). start = time.time() counter = 1</p><p>CharLength = 1 for CharLength in range(25): passwords = (itertools.product(Alphabet, repeat = CharLength)) print("\n \n") print("currently working on passwords with ", CharLength, " chars") print("We are currently at ", (counter / (time.time() - start)), "attempts per seconds") print("It has been ", time.time() - start, " seconds!") print("We have tried ", counter, " possible passwords!") for i in passwords: counter += 1 i = str(i) i = i.replace("[", "") i = i.replace("]", "") i = i.replace("'", "") i = i.replace(" ", "") i = i.replace(",", "") i = i.replace("(", "") i = i.replace(")", "") if i == Password: end = time.time() timetaken = end - start print("Found it in ", timetaken, " seconds and ", counter, "attempts") print("That is ", counter / timetaken, " attempts per second!") print(i) input("Press enter when you have finished") exit()

16th Mar 2018, 5:08 PM
Andrew Bishop
Andrew Bishop - avatar
3 Answers
+ 9
Please save it as a code in Sololearn Playground so people can run it and debug it.
16th Mar 2018, 5:11 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 3
Ok. I found another problem. The algorithm you are using to crack the password is too slow. It will take some time to finish. When that happens, in the sololearn playground you get a "time limit exceeded" : (
16th Mar 2018, 5:53 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 2
one problem I found is that after formating the code you get a ZeroDivisionError. That happens in the expression: counter / (time.time() - start) In the first iteration of the for loop the value of: time.time() - start is zero and that's were you get the error.
16th Mar 2018, 5:48 PM
Ulisses Cruz
Ulisses Cruz - avatar