Skip to content

Tag: python

print python dictionary in particular style

How to print a Python dictionary in this given pattern. I was asked this question in an interview and I couldn’t solve it. Input dictionary: Desired output: Answer Here’s a quick recursive solution: Since each “level” of the dict is built from the next level down, it’s easier to …

how to setup a timer in Python?

I would like to create a timer in Python. After I run the .py class I would like a method to be called every hour in 12 hour period, after 12 hours end the program closes. How can I do this? I want something like: Answer use time.sleep()

My second StringVar fails to show text, shows blank

I was writing a pixel editor in Tkinter, to practice Tkinter and GUI programming. And I was thinking to add a “bottom frame” to show informations like the current tool, the canvas size, etc. But for some reason, the second defined StringVar doesn’t seems to work, while the first one works ju…