Re: [Tutor] Not workin!

2009-10-01 Thread Kent Johnson
On Wed, Sep 30, 2009 at 1:32 AM, Luke Paireepinart
 wrote:
> Oops, thanks for catching that one Marty. I thought they both
> evaluated to false.

They both evaluate to false in a boolean context but that is different
from being *equal* to false or to each other.

In [1]: s = ''

In [2]: bool(s)
Out[2]: False

In [3]: s == False
Out[3]: False

In [4]: l = []

In [5]: bool(l)
Out[5]: False

In [6]: l == False
Out[6]: False

In [7]: s == l
Out[7]: False

Kent

>
> On 9/29/09, Martin Walsh  wrote:
>> Luke Paireepinart wrote:
>>> In this case you are saying "is their input equal to this list with many
>>> elements?" and the answer is always going to be No because a string
>>> won't be equal to a list unless both are empty.
>>
>> I know you probably didn't mean this as it reads, or as I'm reading it,
>> but an empty string and an empty list aren't 'equal' either.
>>
>> In [1]: '' == []
>> Out[1]: False
>>
>> HTH,
>> Marty
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] UnboundLocalError and Break

2009-10-01 Thread Luke Paireepinart
You're using a global variable (playHP) in a function, but you haven't told
the function that playHP is supposed to be a global variable.You're going to
want to change your function definition to:

def monsAttk (damage, attack): #A monsters attack
*global playHP*
*

On Wed, Sep 30, 2009 at 9:13 PM, bob gailer  wrote:
>
> Something is screwy.
> def monsAttk (damage, attack,playHp): # function expects 3 arguments
> monsAttk(4, 15) # passes 2 arguments
>
> That should raise TypeError: monsAttk() takes exactly 3 argument (2 given)
> So something else is awry.

*
That's because Corey originally e-mailed code that he had already modified
rather than the code that was generating the error.  The pastebin code is
different.

Corey, I'm not trying to be an ass, but you're making it difficult for us to
help you and thus we're less inclined to.

On Wed, Sep 30, 2009 at 9:00 PM, Corey Richardson  wrote:

>  Luke Paireepinart wrote:
>
> If your code's more than 10 lines long or so,  put it on pastebin.com and
> send us the link rather than inlining the whole thing.  You could also send
> it as an attachment.
> Your formatting is all screwed up and I can't read the code at all, but I
> have an idea about your error.
>
> Hmmm...thats odd. I didn't do anything differentbut I can do that.
> http://pastebin.com/m518f612f
>
>
>
>>
>>
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with alternate execution

2009-10-01 Thread Dave Angel
You top-posted, and sent the mail to me privately (off-list).  That's 
not how mailing lists work.


wrobl...@cmich.edu wrote:

Thank you for the reply.. I tried putting the print repr(n)
before I defined 'n' with raw_input. My script looks like
this--


def divisible(n):
   if n%3 == 0:
   print n, "is divisible by 3"
   else:
   print n, "is not divisible by 3"
n= raw_input("enter a number= ")
print repr(n)

print divisible(n) 


In the shell, it gives me this error

Traceback (most recent call last):
  File "C:\Users\RY4N\Desktop\CMU
stuff\BIS228\is_divisible_by_3", line 11, in 
print divisible(n)
  File "C:\Users\RY4N\Desktop\CMU
stuff\BIS228\is_divisible_by_3", line 4, in divisible
if n%3 == 0:
TypeError: not all arguments converted during string formatting
--
I don't understand what the problem is

  


You added the print, but you didn't look at the result, did you?

So, what was the repr(n) value?  In particular, what is the type of n ?  
Is it what you expected?


DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with alternate execution

2009-10-01 Thread Dave Angel
You sent the mail to me privately (off-list).  That's not how mailing 
lists work.


wrobl...@cmich.edu wrote:

Thank you for the reply.. I tried putting the print repr(n)
before I defined 'n' with raw_input. My script looks like
this--


def divisible(n):
   if n%3 == 0:
   print n, "is divisible by 3"
   else:
   print n, "is not divisible by 3"
n= raw_input("enter a number= ")
print repr(n)

print divisible(n) 


In the shell, it gives me this error

Traceback (most recent call last):
  File "C:\Users\RY4N\Desktop\CMU
stuff\BIS228\is_divisible_by_3", line 11, in 
print divisible(n)
  File "C:\Users\RY4N\Desktop\CMU
stuff\BIS228\is_divisible_by_3", line 4, in divisible
if n%3 == 0:
TypeError: not all arguments converted during string formatting
--
I don't understand what the problem is

  


You added the print, but you didn't look at the result, did you?

So, what was the repr(n) value?  In particular, what is the type of n ?  
Is it what you expected?


DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor