question
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Fri May 30 02:10:06 EDT 2008
On Thu, 29 May 2008 15:41:29 -0700, Gandalf wrote:
> On May 30, 12:14 am, John Henderson <jhenRemoveT... at talk21.com> wrote:
>> Gandalf wrote:
>> > how do i write this code in order for python to understand it
>> > and print me the x variable
>>
>> > x=1
>> > def aaaa():
>> > x++
>> > if x > 1:
>> > print "wrong"
>> > else :
>> > print x
>>
>> > aaaa()
>>
>> Example:
>>
>> x=1
>> def aaaa(x):
>> x += 1
>> if x > 1:
>> return "wrong"
>> else :
>> return x
>>
>> print aaaa(x)
>>
>> John
>
> mmm isn't their any global variable for functions?
There is but you shouldn't use global variables as they make program and
data flow harder to understand, the code more difficult to test, and
usually couples functions more tightly then they should.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list