Riddle Statements

Riddle supports some basic statements for control flow

if Statement

The if statement evaluates an expression and changes the program flow depending on the result. It uses the if, elif and else keywords, and the optional code blocks are started with : and indented, Python-style:

    if a == 0:
            print("a is zero")
    elif a < 0:
            print("a is negative")
    else:
            print("a is positive")

while Statement

The while statement evaluates an expression and keeps running a code block as long as the expression remains true:

    a = 0:
    while a < 10:
            a = a + 1

for Statement

The for statement iterates on the values of a range

    for a in [1,2,3]:
            print(a)

break Statement

The break statement can provide an exit from the closer while or for loop:

    a = 0:
    while true:
            a = a + 1
            if a == 10:
                    break

return Statement

The return statement interrupts the entire function and optionally returns a value.