Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Can You Please Spot the Error in the Following Python Code?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 439
    Answer it

    How to display a powerset using the following code? what is the mistake and where? why the output is not getting displayed? What to do to display the output?

     

    def power_set(items):
        N = len(items)
        # enumerate the 2 ** N possible combinations
        for i in range(2 ** N):
            combo = []
            for j in range(N):
                # test bit jth of integer i
                if (i >> j) % 2 == 1:
                    combo.append(items[j])
            yield combo

 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: