1

I'm running a student database and using python 2.7 on pycharm. Here is the script

FirstName = input("Enter the Student's first name")
    if not FirstName or type(FirstName) != str:
    print("Enter a real name silly")
    exit()

and the create Table stement looks like so

drop table if exists StudentID;
drop table if exists FirstName;
drop table if exists LastName;
drop table if exists GPA;
drop table if exists Major;
drop table if exists FacultyAdvisor;
CREATE TABLE Student(
  StudentID int PRIMARY KEY AUTOINCREMENT ,
  FirstName varchar(25),
  LastName varchar(25),
  GPA NUMERIC,
  Major varchar(10),
  FacultyAdvisor varchar(25)
)

and the error I'm getting is

FirstName = input("Enter the Student's first name")
  File "<string>", line 1, in <module>
NameError: name 'john' is not defined
3
  • Whats the error you're seeing ? Commented Feb 26, 2019 at 22:41
  • @AK47 sorry, just updated the post Commented Feb 26, 2019 at 22:46
  • You are using Python2 I assume. Use raw_input() instead of input() Commented Feb 26, 2019 at 22:48

1 Answer 1

1

My guess is that you're using Python2

You need to use the raw_input() method when receiving String input from the user:

FirstName = raw_input("Enter the Student's first name")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.