Skip to content
Advertisement

Tag: python-3.x

List index out of range for Python

I have a question regarding the following exercise: In this function, I print lastrecord.fetchall()[0][0] and quantity.get to make sure they are float. So the program prints in that case: 5.0 for lastrecord.fetchall and quantity.get Up to now, no problem, but when I try to us them up, it gives me an error of List Index Out Of Range, so program

How to find the maxValue’s line number in one loop?

here’s the code: Tips how to simplify the code are welcome I would like to find a position of the line that contains the max value(already found that value) I know i can just use another loop to find the placement, but i wonder if there’s a shorter and more efficient way to do it Answer There’s a method to

How to obtain a value from inside a loop

I will be implementing multiprocessing so that the loops are occurring at the same time, but how can I make it so at the end of each iteration, I can obtain the value of westernEurope.cases and easternEurope.cases so that I can add them together Answer IMHO there is no need for multiprocessing. With a generator, your problem can be solved

Pytest: Nested use of request fixture

I’d like to get some help on how to run pytests with multiple layers of parameterized pytest fixtures. I have a global request-based fixture for selecting a base implementation of the system I’d like to test: I’d like to now run some additionally-parametrized tests against different test cases on the backend. Using these two layers of fixtures, I’d like to

All unique combinations of a set of sets of values

If I have an arbitrary amount of elements, each with a specified set of values, what can I do to get all possible combinations with a value from each element’s set? For example, let’s say I have: What can I do to get the following? Input/output don’t need to use dicts, but I figured that’s the easiest way to represent

How do I use colorama inside a tuple?

I’m trying to change individual existing lines inside an existing tuple. Example: I want ID to be one color, Name, Age, Condition, Medicine, Temperament, and Adoptable to be a different color. I can’t figure out how to enter the escape codes for color inside the existing tuple. Help! Answer You need to prepend Fore.<COLOR> and preferably append Style.RESET_ALL to every

Advertisement