Cicada’s while...do loop is pretty similar to C’s while loop, except that the logical condition goes between the while keyword and a do keyword instead of inside parentheses. Also, the logical operators are somewhat different and we use parentheses to group multi-line commands, in the same way as with the if statement.
while input() /= "pleeez" do print("what's the magic word? ")
while input() == "thank you" do (
print("you are welcome!\n")
print("anything else? ")
)
There are two differences between Cicada’s loop loop and its while loop. First, the break condition of a loop loop is evaluated at the end of the loop, so it always runs at least once. Second, it is a loop...until loop, not a loop...while loop, so it keeps looping as long as the logical condition is not satisfied.
attempt := 0
loop (
print("Thank you!\n")
attempt = attempt+1
) until input() == "you're welcome"
loop print("> ") until input() == "exit"
Last update: May 8, 2024