Please I am having challenges to write a code with notepad and then run it with IDLE 2.6 particularly when importing modules like turtle.

Here is an example:

here is python code :

# Programme pour dessiner une série de triangles équilatéraux de différentes couleurs en différent endroit.
from turtle import *                   	# Nous importons tous le module turtle
def triangle(hauteur, couleur):         # Nous allons construire le triangle équilatéral

reset()                                 # Effacons l'affichage graphique

f = int(raw_input('Hauteur du triangle'))       # hauteur de notre triangle
e = 1
while e < 6 :
        color = raw_input('Entrez la couleur')
        goto(e*f+50, f)
        triangle(f, color)
e = e + 1

I receive this error message:
Traceback (most recent call last):
File "D:\Logiciel\PYTHON\Exercices\", line 2, in <module>
from turtle import * # Nous importons tous le module turtle
File "D:\Logiciel\PYTHON\Exercices\", line 2, in <module>
NameError: name 'forward' is not defined

Please what is it that I am not doing right?
Kind regards


Recommended Answers

All 2 Replies

Your folder D:\Logiciel\PYTHON\Exercices contains a suspicious file which is probably not the module turtle from python's lib-tk. So check this file, and rename it if necessary.

Python checks in the working directory first, and if you save one of your own files with a module name, you don't get the proper module.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.