Example Basic Number Guesser

ASnake Documentation

Table Of Contents

    A code which generates a random number to guess, then guesses random numbers until it matches. Due to being random, the result will likely differ each time.

    Code:

    from random import randint
    int:
        num is randint(0,9)
        guess is randint(0,9)
        tries 0
    while guess isnt num
        guess is randint(0,9)
        ++tries
    f'number was {num}, took {tries} tries'
    

    (Potential) Result:

    number was 1, took 20 tries
    
    Scroll to top