Skip to content

Tag: python-3.x

Tkinter import filedialog error

I’m trying to use tkinter with python3 to open an image, see here a piece of code : I have installed python3-tk, and I have the demo window when I write in the terminal. I tried several combinations that did not work : gives , gives I tried with _tinker , FileDialog, file_dialog, but I always have &#822…

Python – Brute force generator

I’ve made a brute force password cracker which works, but I also made a string combining generator which would be better as the brute force string generator; however I can’t figure out how to combine the two. Brute force code: Character generator code: I would like to replace the “Generating…

find words of length 4 using regular expression

I am trying to find words in regular expression with length 4 I am trying this but I am getting an empty list: What is wrong with my code ? my input is: here we are having fun these days my expected output: [‘here’, ‘days’] my output: [] Answer Use word boundaries b. When you add ancho…

Python3 exec, why returns None?

When the code below this text, and returns the result None why? Result: Module code exx.py: Answer The problem of course is not only that print returns None, it is that exec returns None, always. If you’d need the return value, you’d use eval: after which you’d notice that print still return…

Reduce multiple blank lines to single (Pythonically)

How can I reduce multiple blank lines in a text file to a single line at each occurrence? I have read the entire file into a string, because I want to do some replacement across line endings. This doesn’t seem to work and nor does this It’s easy enough to strip them all, but I want to reduce multi…