[Tutor] [Fwd: Re: trouble with "if"]

Andre Engels andreengels at gmail.com
Wed May 30 08:53:04 CEST 2007


2007/5/30, Brian van den Broek <broek at cc.umanitoba.ca>:
> Another fwd, folks.
>
> Brian vdB
>
> -------- Original Message --------
> Subject: Re: [Tutor] trouble with "if"
> Date: Tue, 29 May 2007 23:28:46 -0500
> From: Adam Urbas <jped.aru at gmail.com>
> To: Brian van den Broek <broek at cc.umanitoba.ca>
> References: <BAY103-W11DE2E62FD41449A952D68B12F0 at phx.gbl>
> <465C64A4.60602 at cc.umanitoba.ca>
> <ef52818c0705292107n1ee0c105k54c02ccf4d85f7c6 at mail.gmail.com>
>
> I'm having trouble with the parentheses after the def thing().  IDLE
> says that there is something wrong with it.  If I type something
> between them, it says that there is something wrong with the quotation
> marks.  If I just leave it like (), then it says that something is
> wrong with what is after the parentheses.  Unless my code is supposed
> to go between the parentheses.  I'll try that.

Between the parentheses should go the variables you use (if any) when
calling the function. For example:

def sayhello():
    print "Hello"

You don't have any parameters here, so there's nothing between the brackets

def say(word):
    print word

Now there is one parameter, namely word.

def sayboth(word1,word2):
    print word1
    print word2

Here there are two parameters, word1 and word2.

The number of parameters should be the same as the number of
parameters you use when calling the function:

sayhello()
say("One text")
sayboth("One text","Another text")

There is a much used method to make some of the parameters optional,
but we'll not go into that.

To know what is going wrong with your program, I would have to see the
program (or a simplified version of it that still goes wrong) and
preferably also the exact error message you are getting.


-- 
Andre Engels, andreengels at gmail.com
ICQ: 6260644  --  Skype: a_engels


More information about the Tutor mailing list