Reputation: 11
When I run this simple script and enter information an error appears which says: Name error: name'...' is not defined
.
Name = str(input("Enter the name of your friend: "))
Age = int(input("Enter age of that friend: "))
print("The name of your friend is {} and their age is {}".format(Name, Age))
Upvotes: 0
Views: 1431
Reputation: 504
I have modified your code to the correct state:
name = str(input("Enter the name of your friend"))
age = int(input("Enter age of that friend"))
print("The name of your friend is {} and their age is {}".format(name, age))
There were three errors:
p of print needs to be lowercase and
a closing parenthesis was missing
f of format also needs to be in lowercase.
Upvotes: 1
Reputation: 1426
To expand on Tarun Guptas answer, the convention in python is that function names always start with lowercase letters. Uppercase first letters are reserved for classes. All the inbuilt functionality of python sticks to these conventions. The same is true for variable names, never start them with uppercase letters.
If you find yourself hunting a lot after syntax errors, get yourself an editor with a good python linter, that is, inbuilt functionality that checks the code on the fly. This will help you make quick progress in avoiding the most common mistakes.
As you advance in python, you should really check out the python style guide. Most of the conventions in python are not strictly mandated by the language, however if you ever plan to interact with other programmers, they will hate you with a passion you if you don't stick to pep8.
Upvotes: 1