I have defined a simple function in Python that takes 'Strings' as an argument and tried to manipulate the code a bit, and saw a difference while calling the function with those two codes.
This is the first code:
def my_name(first_name,last_name):
first_name = input('enter the first name:')
last_name = input('enter the last name:')
print(first_name+' ' + last_name)
my_name('first_name','last_name')
In this program, I need to use quotation marks with the argument and if I don't use them I get an error. Why is this so?
But for the second program, I don't need to use quotation mark if I still use them, I don't get any find of error but for the previous program I have to use quotation otherwise it results in an error.
Please help. Here are snippets of my code: First code: enter image description here
Getting error while running without quotation enter image description here
Second code: enter image description here
Thanks in advance!!
my_namefunction, if you remove the lines that have the input() it will printfirst_name last_nameand when you remove the quotation you are passing as a parameter 2 variables that are not have been initialized and need to receive values (which happens in the second code).