Yes, yes, yes!#
Look at the example of this small program where we introduce the if
(if) instruction to
test a condition:
from laby.global_fr import *
from random import randint
c = "r " if randint(0,1) == 1 else ". "
carte = "o o o o\n"
carte+= "o → " + c + " x\n"
carte+= "o o o o\n"
Laby(carte = carte)
debut()
if regarde() == Caillou:
prend()
avance()
gauche()
gauche()
pose()
droite()
droite()
else:
avance()
ouvre()
Below, the large web (Toile
) blocks the passage, but not the small web (
PetiteToile
). Be careful, they are not always in the same place! Use if
and
regarde()
to find the right passage in all cases.
???
if regarde() == Toile:
???
else:
???
from laby.global_fr import *
Laby(niveau = "3a")