0

I use Sublime Text and have a problem with that code:

#coding: utf-8

import turtle

turtle.circle(20)

answer = turtle.textinput("Title", "Text")

When i run it, i get:

AttributeError: 'module' object has no attribute 'textinput'

How can i fix it?

3
  • You don't mention your Python version. Maybe this is relevant? stackoverflow.com/questions/20105816/… Commented Jan 16, 2017 at 11:07
  • 1
    Always provide the full traceback when reporting errors, so we can see where it was triggered. Please also provide the desired result of your program (i.e. what are you trying to do?) Commented Jan 16, 2017 at 11:08
  • Thank you. The problem was in Python 2. I thought it was Python 3. I'll try to provide the full information next time. Thank you Commented Jan 16, 2017 at 11:52

2 Answers 2

1

dir(turtle) will list all the methods and attributes available in turtle module. In python 3.4, answer = turtle.textinput("Title", "Text") is working. You can check if you have latest python and latest module installed.

Sign up to request clarification or add additional context in comments.

Comments

0

You are using Python 2.

Run

import sys
print(sys.version)

and it will probably output something like

2.7.12 (v2.7.12:d33e0cf91556, Jun 26 2016, 12:10:39) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]

which means that you are using Python 2.

As roganjosh pointed out, Python 2's turtle module does not have the command textinput. If you want to run that code, you need to use python 3. If you are unsure how to switch versions, leave a comment on this post saying how you installed Python, and how you run your programs, and I'll show you how to use Python 3 instead.

If you want to continue with Python 2, then instead of that command you have to run

import tkSimpleDialog
answer = tkSimpleDialog.askstring("Text", "Text")

which does exactly the same thing.

1 Comment

Yes, i was using Python 2. Thank you for help me to realize that. I know how to switch the version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.