[Tutor] How do fix this error?

mailing list ml.cyresse at gmail.com
Sat Sep 17 08:16:55 CEST 2005


raw_input takes one argument.

While 

>>> x = 5
>>> b = 10
>>> print x, "+", b, "=", x+b 

will print 5 + 10 = 15, you could also have written it - 
>>>print str(x) + " + " + str(b) + " = " + str(x+b)

Now, if I have a function - 

def divByTen(number):
      return number/10

I can call it like so - 

>>>divByTen(100)
10

or

>>>divByTen(50+50)
10

As Python will resolve 50+50 first.

However, 

>>>divByTen(50,50)

will produce this error - 

TypeError: divByTen expected at most 1 arguments, got 2


See where I'm going with this?

One more thing, the comma only works for the print command. 
On 9/17/05, Poor Yorick <tutor.python.org at pooryorick.com> wrote:
> Nathan Pinno wrote:
> 
> >     guess = float(raw_input(a," + ",b," = "))
> > TypeError: [raw_]input expected at most 1 arguments, got 4
> >
> 
> >     guess = float(raw_input(a," + ",b," = "))
> >     return answer, guess
> >
> hint:  how many arguments are you passing to raw_input here?
> 
> --
> Poor Yorick
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list