Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to change itertools.product parameters while running

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 160
    Answer it

    Hi, I'm new in Python, so excuse me if the question may be too simple for someone.

    I have the following code:

    from itertools import product
    
    for a,b in product(range(0,10), range(a,10)):
        print (a,b)

    but it does not work, a message error tell me that in the range is not defined.

    It must work like this:

    for a in range (0,10):
        for b in range (a,10):
            print(a,b)

    I can't use the second solution because I need to nest variable multiple loops.

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: