Reputation: 1
This function asks the name
def printName():
print("Enter your name: ")
n=input()
printName()
The if statement checks if n is equal to Python
if n=="Python":
print("Welcome")
else:
print("Try again")
Upvotes: 0
Views: 4622
Reputation: 40973
n
is only defined inside the function. This should work:
def printName():
print("Enter your name: ")
n=input()
if n=='Python':
...
Alternatively you can also do:
def printName():
print("Enter your name: ")
n=input()
return n
n = printName()
# now you can use n
Upvotes: 1