All Questions
3 questions
0
votes
1
answer
55
views
Nesting iteration - difference between for and while loops
I need to do a nested iteration over a generator (not a list).
What I need is to perform something like this:
testing 3 ...
Testing passed!
Starting subtest:
Sub-testing 4 with 3
Sub-...
0
votes
4
answers
354
views
How to print all possible combinations of a list that have the same sum as the original list?
I am trying to print all possible combinations of a list but only if the combinations add up to a number.
lst = [0, 1, 2] #The goal is print all combinations that sum up to 3
import itertools
def ...
5
votes
3
answers
2k
views
Is there any case in python when using a while loop would be best practice?
I'm doing some python benchmarking, and I've discovered that repeat(None) is much faster than while True or while 1:
>>> def bench7():
... foo = 0
... a = time()
... for i in repeat(...