0

I am not able to use join with ' & ' with list operand. Any help would be appreciated!

def axiom_generator_at_most_one_wumpus(xmin, xmax, ymin, ymax):
    """
    Assert that there is at at most one Wumpus.

    xmin, xmax, ymin, ymax := the bounds of the environment.
    """

    axiom_str = ''
    options = []
    for x in range(xmin, xmax+1):
        for y in range(ymin, ymax+1):
            option = wumpus_str(x,y) + " >> ("
            notWumps = []
            for xtemp in range(xmin, xmax+1):
                for ytemp in range(ymin, ymax+1):
                    if xtemp != x and ytemp != y:
                        notWumps.append('~' + wumpus_str(xtemp,ytemp))
            option += ' & '.join(notWumps)
            option += ')'
            options.append(option)
    axiom_str += ' & '.join(options)
    return axiom_str
ti7
  • 16,375
  • 6
  • 40
  • 68
Akshit A.
  • 27
  • 4
  • What happens that you're not expecting? I suspect something else is awry as joining a list like this should work fine: `>>> ' & '.join(["a", "b"])` `'a & b'`. – ti7 Apr 06 '18 at 06:02
  • I am getting an error message for the argument in join method to be string. "Expected string, found list" – Akshit A. Apr 06 '18 at 07:21
  • Welcome to StackOverflow. Please read and follow the posting guidelines in the help documentation, as suggested when you created this account. [Minimal, complete, verifiable example](http://stackoverflow.com/help/mcve) applies here. We cannot effectively help you until you post your MCVE code and accurately describe the problem. We should be able to paste your posted code into a text file and reproduce the problem you described. – Prune Apr 06 '18 at 18:25

0 Answers0