[Tutor] How do fix this error?

Alan G alan.gauld at freenet.co.uk
Sat Sep 17 11:12:19 CEST 2005

Traceback (most recent call last):
  File "D:\Python24\add_tutor.py", line 18, in -toplevel-
    answer, guess = add(num1,num2)
  File "D:\Python24\add_tutor.py", line 5, in add
    guess = float(raw_input(a," + ",b," = "))
TypeError: [raw_]input expected at most 1 arguments, got 4

The error tells you what to do - give raw input 1 argument:

    guess = float(raw_input(a," + ",b," = "))

The commas separate the arguments. You need to create 
the prompt string first and then feed it to raw_input.

The string formatting operators may help here. 
See the Simple Sequences topic on my tutor for 
examples of string formatting.

Alan G
Author of the Learn to Program web tutor

More information about the Tutor mailing list