Here's my question:
How can I dynamically append elements from a "for each in range(x)" sort of loop onto a string that has not yet been defined?
Example:
- Code: Select all
encrypt = '5e9i=57m'
for each in range(len(encrypt)):
pw += chr(ord(encrypt[each]) - each)
Traceback (most recent call last):
File "<pyshell#154>", line 2, in <module>
pw += chr(ord(encrypt[each]) - each)
NameError: name 'pw' is not defined
It worked once I went back and deliberately introduced pw
- Code: Select all
pw = ''
for each in range(len(encrypt)):
pw += chr(ord(encrypt[each]) - each)
Anyway, how can I avoid the pw = '' declaration? Is it possible?
Andrew


