Rulala
Rulala

Reputation: 1

Turtle commands on Python

Can someone please help me with the following lines of code, and explain why nothing seems to be happening:

Many thanks,

from turtle import *
import time

def poly( n, N ):
    """ draws n sides of an N-sided regular polygon """
    if n == 0:
        return
    else:
        forward( 50 )   # 50 is hard-coded at the moment...
        left( 360.0/N )
        poly( n-1, N )
        poly( 7, 7)
        return


def chai(size):
    """ our chai function! """
    if (size<50): 
        return
    else:
        forward(size)
        left(90)
        forward(size/2.0)
        right(90)
        right(90)
        forward(size)
        left(90)
        left(90)
        forward(size/2.0)
        right(90)
        backward(size)
        return

Upvotes: 0

Views: 540

Answers (2)

Kristy Hughes
Kristy Hughes

Reputation: 596

You need to call your functions. So at the bottom type chai(100) or poly(4, 6) or whatever it is that you want to call. Alternatively you can import these functions in the shell, another file, or wherever you want to call them and run them there.

Upvotes: 1

yask
yask

Reputation: 4278

You declared functions, but you never called them. It appears to be running fine.

poly(2,3) enter image description here

Upvotes: 0

Related Questions