This article has been dead for over six months: Start a new discussion instead

0

I can't get this to generate random shapes, etc. Basically what I need to do is randomly generate similar lists consisting of:

combinations of 'square', 'triangle', 'circle' and 'left'.

And random numbers from 1 to 10 for physical dimensions and 10 to 90 for angles

Have the program use 'split' to divide the numbers from the commands so that the turtles can have more variety in their random creations.

Any help would be greatly appreciated, I think I've reached a roadblock :p

```
import turtle
import random
import math
import time
my_screen = turtle.Screen()
my_turtle = turtle.Turtle()
turtle_commands = ['square 20','circle 20','triangle 20', \
'left 15 40','left 70 40',\
'left 90 40', 'straight 50']
number = int(input('Input a random positive number: '))
def get_random_turtle_commands(number):
new_list = []
i = 0
##for i in number:
while(i < number):
i=i+1
index=math.ceil(random.random()*len(turtle_commands)-1)
new_list=index.append(turtle_commands[index])
return(new_list)
def draw_square(side):
for number in range(4):
turtle.fd(side)
turtle.left(90)
def draw_triangle(side):
for number in range(3):
turtle.fd(side)
turtle.left(60)
def draw_movement(degree,length):
turtle.left(degree)
turtle.fd(length)
def turtle_command(string):
turtle.pd()
if string == 'square 20':
draw_square(20)
elif string == 'circle 20':
turtle.circle(20)
elif string == 'triangle 20':
draw_triangle(20)
elif string == 'left 15 40':
draw_movement(15, 40)
elif string == 'left 70 40':
draw_movement(70,40)
elif string == 'left 90 40':
draw_movement(90,40)
elif string == 'straight 50':
turtle.fd(50)
turtle.pu()
def final_output():
for x in string:
turtle_command(string)
def main():
get_random_turtle_commands(number)
final_output()
main()
```