Python Forum
How to use positional arguments
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use positional arguments
#1
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?
Reply
#2
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
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error TypeError: output_type_handler() takes 2 positional arguments but 6 were given paulo79 1 1,922 Oct-17-2022, 06:29 PM
Last Post: paulo79
  TypeError: missing 3 required positional arguments: wardancer84 9 10,822 Aug-19-2021, 04:27 PM
Last Post: deanhystad
  TypeError: max_value() missing 2 required positional arguments: 'alpha' and 'beta' Anldra12 2 4,198 May-15-2021, 04:15 PM
Last Post: Anldra12
  How to reuse positional arguments entered in terminal. rcmanu95 1 1,866 Jul-04-2020, 01:00 AM
Last Post: bowlofred
  random.choice() takes two positional arguments, but three were given. ShakeyPakey 5 11,630 May-31-2020, 03:13 PM
Last Post: deanhystad
  TypeError: add() missing 2 required positional arguments NectDz 5 13,044 May-28-2020, 02:54 PM
Last Post: BitPythoner
  add() takes 2 positional arguments but 3 were given Man_from_India 3 5,752 Feb-10-2020, 05:08 PM
Last Post: Man_from_India
  takes 21 positional arguments but 24 were given sophsoph 5 3,827 Jun-21-2019, 12:53 AM
Last Post: ichabod801
  python 3.8 and positional arguments vojo 4 2,774 Jun-10-2019, 10:00 PM
Last Post: DeaD_EyE
  Missing 2 Required Positional Arguments: SwiftWater 1 19,975 Feb-28-2019, 08:57 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020