lundi 11 septembre 2017

Python if-else statement order

My problem is similar to this one: Python if-elif statements order but the answer is:

    directions = []
        if <the obstacle has a free tile on its RIGHT>:
              directions.append(move_right)
        if <the obstacle has a free tile on its LEFT>:
              directions.append(move_left)

    if not directions:
          stop()
    else:
         random.choice(directions)()

Now, my question is how do you input if statements into a list direction=[] ? Is it a valid data type?

Aucun commentaire:

Enregistrer un commentaire