New Python guy here, kinda pulling my hair out on this one. Running Python 3.6, Windows... I know "NameError: name '--' is not defined" has plenty of posts, but I honestly haven't been able to resolve this from any of them, so pardon any repetitiousness. ANYway, here's the trouble:
def char_swap():
swapped_a = [l.replace('a', '@') for l in lines]
swapped_s = [l.replace('s', '$') for l in lines]
swapped_i = [l.replace('i', '!') for l in lines]
swapped_o = [l.replace('o', '0') for l in lines]
global swapped
swapped = [swapped_i,swapped_o,swapped_s,swapped_a]
print(swapped)
return swapped
def numberAdd():
added = [n+(str(random.randint(0,9999))) for n in swapped]
print(added)
return added
Here, 'lines' is a previous list within the full code. The error is "NameError: name 'swapped' is not defined"
What's almost more boggling to me is that the 'char_swap' function is working just fine, and it's referencing 'lines', which was setup and defined pretty much verbatim how I've defined 'swapped' here. Global, gave it a list value, and off we go. In fact, if I swap out 'swapped' in the numberAdd() function for 'lines', it does its job just fine.
Any help is much appreciated!