I have a simple script here and i want to use the user input from my_function as argument for my otehrfunction:
def otherfunction(lname):
print("This is the otherfunction. " + lname + " is your lastname")
def my_function():
#b = "Black"
b = input("Enter your name: ")
otherfunction(b)
my_function()
when i use variable b and set it to b= "Black", the script does what it is supposed to do but when i say b = input(....) i get this error:
Enter your name: black
Traceback (most recent call last):
File "function.py", line 44, in <module>
my_function()
File "function.py", line 41, in my_function
b = input("Enter your name: ")
File "<string>", line 1, in <module>
NameError: name 'black' is not defined
black
. And this is not written in the code so it must be the user input. Now why would a user input be giving this error ?? Python could not identify the input means it was being treated as some variable or keyword or command. This would happen if it is not a string. This is how I could understan the issue.