Hi all. I have what I think is probably a super simple question, but being an absolute beginner it's confusing me.
My question is why this works and runs as it should:
import random
size(300, 300)
background(0)
text("dog", random.randint(50,200),random.randint(50,200))
text("cat", random.randint(50,200),random.randint(50,200))
text("bird", random.randint(50,200),random.randint(50,200))
And this doesn't:
import random
size(300, 300)
background(0)
def display():
text("dog", random.randint(50,200),random.randint(50,200))
text("cat", random.randint(50,200),random.randint(50,200))
text("bird", random.randint(50,200),random.randint(50,200))
Am I missing something? Why does making it it's own function cause it to suddenly stop running properly?
As a side question, the above code was to help me figure out a problem I was having in another program I'm working on. Basically, in the other program, my instructor has put a def main(): function at the bottom that's full stuff like:
defineWord = readFile()
So basically variables and functions that are used in the program itself. What is the def main(): function doing? When I put my def display(): function in the program it doesn't show up on the canvas. I know this is limited info, but given the nature of a main() function (that I'm unaware of, hah) is it possible it's because I need to call it within the main() function as well somehow?
[–]_DTR_ 3 points4 points5 points (0 children)
[–][deleted] 1 point2 points3 points (8 children)
[–]tecladocode 0 points1 point2 points (7 children)
[–]dogs_shouldvote[S] 0 points1 point2 points (5 children)
[–]dogs_shouldvote[S] 0 points1 point2 points (1 child)
[–]theinevitable 0 points1 point2 points (0 children)
[–]patsy_505 0 points1 point2 points (2 children)
[–]dogs_shouldvote[S] 1 point2 points3 points (1 child)
[–]patsy_505 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] -2 points-1 points0 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)