Today we are building a program that writes a random “painting” in the terminal. We use a list of ASCII-Symbols as our paint. The output looks like this:
Our “art” will win no prizes but we use a function with two for-i-in-range-loops.
from random import randint # so we can use random/randint
def get_artsy(size):
line = ""
ascii = ["█","$","≡","╬","¿","▒","░"] # our ascii canvas-symbols
for i in range(0,int(size)):
line = line + ascii[randint(0,6)] # building the random line of ascii-symbils
for x in range(0,int(size)):
print(line*2) # double the line before printing so we get a more square canvas
get_artsy(input("Enter the size of the painting: "))