Skip to content

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 …

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&#821…

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 generat…

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 cas…

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&#82…