mardi 23 février 2021

How to solve cannot assign to function call in python?

I am supposed to write function randomWorld. It takes in two integers width and height which represent the width and height of the world and returns a dict that represents the world. I have been following the teacher algorithm idea but I am getting this SyntaxError cannot assign to function call and this is what I have done

def randomWorld(width, height):
    """Return a random world"""
    world={}
    for x in range(width):        
      for y in range(height):
        if random.randint(0,10) < 3:
         world.Cell(x,y)=True
    return world



Aucun commentaire:

Enregistrer un commentaire