Hi i was just wondering if anybody could help me with this code.
#! /usr/bin/env python
# -*- coding: UTF-8 -*-
import turtle
def initialize ( color = "blue" , smallest = 1.0 ) :
turtle.clear ( )
turtle.up ( )
turtle.goto ( -100.0 , 100.0 )
turtle.setheading ( 0 )
turtle.color ( color )
turtle.down ( )
global smallestLineLength
smallestLineLength = "smallest"
def TornSquare ( overallLength ) :
halfSideLength = ( 0.9 * overallLength ) / 2.0
if 'halfSideLength' <= smallestLineLength :
moveFunction = turtle.forward
else :
moveFunction = cesaroLine
a = 85
b = 180 - 2 * a
moveFunction ( 'halfSideLength' )
turtle.right ( a )
moveFunction ( 'halfSideLength' )
turtle.left ( 180 - b )
moveFunction ( 'halfSideLength' )
turtle.right ( a )
moveFunction ( 'halfSideLength' )
def TornSquareFractal (overall , smallest = 1.0 , color = "blue") :
cesaroLine ( overall )
turtle.right ( 90 )
cesaroLine ( overall )
turtle.right ( 90 )
cesaroLine ( overall )
turtle.right ( 90 )
cesaroLine ( overall )
if __name__ == "__main__" :
#initialize ( ’brown’ , 100 ) ; cesaroLine ( 200 )
TornSquareFractal ( 200.0 , 10.0 , "brown" )
raw_input ( "Press enter to end" )
Everytime i run it i get this error:
Traceback (most recent call last):
File "C:/Python27/torn square.py", line 21, in <module>
moveFunction ( 'halfSideLength' )
File "<string>", line 1, in forward
File "C:\Python27\lib\lib-tk\turtle.py", line 1554, in forward
self._go(distance)
File "C:\Python27\lib\lib-tk\turtle.py", line 1521, in _go
ende = self._position + self._orient * distance
File "C:\Python27\lib\lib-tk\turtle.py", line 277, in __mul__
return Vec2D(self[0]*other, self[1]*other)
TypeError: can't multiply sequence by non-int of type 'float'
Can anybody help me see where i am going wrong?