Skip to content

Tag: python

How to limit incorrect answers from users input?

I’m here with my code, here you can see it: Let me explain: I defined false for, if user inputs the answer 3 times and all of them for that question are false, show user the answer and continue asking Actually this code asks 10 different math questions, this is a part of my code, I’m checking if a…

Pandas apply same filtering on two dataframes

I have two pandas dataframes with the same indexes and lengths. However, they might contain nans at different places. See, example input below: I want to do some calculations where I want to remove indexes in both the dataframes even if one of them has a NaN values. So, in those case only the first row is val…

Getting the colour of a particular pixel with opencv

I’m trying to determine the colour of a single pixel in an image using Python and OpenCV. However, when I read the BGR values from that pixel and use those same values to draw a circle back on the image, the colours do not match. Where am I going wrong? Output: Note the cyan circle drawn on the yellow r…

How to access a multiple dictionary in python?

I have a following dictionary: Lets suppose I would like to print a value using print(pokus[1][“ahoj”][0][“visit”][0]). But I nedd [1][“ahoj”][0][“visit”][0] to be in an extra variable. I try this: But I get an error TypeError: list indices must be integers or s…

Cannot Locate my Module from another folder n python

I’ve the following structure in my simple python project: The tokengenerator.py module produces Token variables and I need to call it in generatedata.pymodule and I used the following code line for this purpose: but it returns the error below: Would you please advise ? Answer from this article, you can …