B
Brian Alexander
I remember using a language many years ago that permitted the creation
of temporary, local variables within the body of a loop (and perhaps
other statement blocks.) Maybe it was Turing.
Can Python do this?
---
EX:
---
for i in listOfNames:
prefixMr = 'Mr'
prefixMs = 'Ms'
if i in mansName:
salutation = prefixMr + i
else:
salutation = prefixMs + i
print 'Hello,' + salutation
----
The idea is that all variables created within the for statements will be
forgotten once the loop exits. No need to exit the procedure.
Is this possible?
Many thanks,
Brian.
of temporary, local variables within the body of a loop (and perhaps
other statement blocks.) Maybe it was Turing.
Can Python do this?
---
EX:
---
for i in listOfNames:
prefixMr = 'Mr'
prefixMs = 'Ms'
if i in mansName:
salutation = prefixMr + i
else:
salutation = prefixMs + i
print 'Hello,' + salutation
----
The idea is that all variables created within the for statements will be
forgotten once the loop exits. No need to exit the procedure.
Is this possible?
Many thanks,
Brian.