Python Forum

Full Version: How to use positional arguments
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I tried to test my program (I'm using IDLE), but I got the following error in Python 3.6.2 Shell:
TypeError: textinput() missing 1 required positional argument: 'prompt'

#WhileLoopNameSpiral

import turtle
t = turtle.Pen()
turtle.bgcolor("black")
colors = ["red", "yellow", "blue", "green", "orange",
          "purple", "white", "brown", "gray", "pink"]
family =[] #empty list for family names

name = turtle.textinput("It's time to build a list of family names.",
                        "Enter a name, or just hit [ENTER] to quit:")
#keep asking for names
while name != "":
    family.append(name)
    name = turtle.textinput("Enter another name,or hit [ENTER] to quit:")

#draw a spiral of the names on the screen:
for x in range(100):
    t.pencolor(colors[x%len(family)])#rotate through the colors
    t.penup()#do not draw the regular spiral lines
    t.forward(x*4)#just move the turtle to the next spiral angle
    t.pendown()#draw the next family member's name
    t.write(family[x%len(family)], font = ("Arial", int((x+4)/4), "bold"))
    t.left(360/len(family) + 2)#turn left for our spiral
The shell says the error is in line 15 of my code. This is a syntax error I presume?
turtle.textinput takes two positional positional parameters, a title for the pop up window and a prompt detailing the response needed. You only provided one, so turtle assume it was the title, and wanted to know where the prompt was.

It's always good to check the documentation on errors like this: https://docs.python.org/3.5/library/turt....textinput