So the below code works fine:
numOfPasswordsGiven = input("How many passwords should this program generate? ")
lengthOfPasswordsGiven = input("How long should these passwords be? ")
print(numOfPasswordsGiven)
print(lengthOfPasswordsGiven)
But the code below doesn't:
def testing () :
numOfPasswordsGiven = input("How many passwords should this program generate? ")
lengthOfPasswordsGiven = input("How long should these passwords be? ")
testing()
print(numOfPasswordsGiven)
print(lengthOfPasswordsGiven)
When I run this second snippet of code, I get the following error:
Traceback (most recent call last):
File "main.py", line 8, in <module>
print(numOfPasswordsGiven)
NameError: name 'numOfPasswordsGiven' is not defined
I've debugged the program. It looks like lengthOfPasswordsGiven isn't being passed the value that I entered when prompted, in the second code snippet. But the value is getting passed to this variable in the first code snippet.
I've also tried putting the input statements in two different definitions. The same error occurs.
How do I fix this?