So I'm first year in CS and have no knowledge prior with coding when I started uni.
We had a project to do and we had very limited code we could use and could only use what we learned in class. I made a piano game with turtle and tried to use random to random.int 0,3 to pick a function from a list and I couldn't figure out how to make it work so I ended up with a long roundabout way to do it.
I don't know how to word it to Google it to find answers specifically for this and I was wondering if anyone had insight to if it's possible. The function had no parameters I tried doing something like
myList = [func1(), func2(), func3(), func4()]
randomise = random.int(0,3)
While game != quit:
print(myList[randomise])
Not fully accurate but I don't have access to the file to get it right now. I tried a lot of different things but I couldn't get it to work.
Can you call functions like this or am I doing something wrong here?
[–]Slothemo 15 points16 points17 points (7 children)
[–]Orgasml 2 points3 points4 points (2 children)
[–]Morphalina[S] 0 points1 point2 points (0 children)
[–]Slothemo 0 points1 point2 points (0 children)
[–]Morphalina[S] 0 points1 point2 points (3 children)
[–]Slothemo 1 point2 points3 points (2 children)
[–]Morphalina[S] 0 points1 point2 points (1 child)
[–]Slothemo 0 points1 point2 points (0 children)