-1

Im making a program that will ask the user for their first name and surname. This data is then saved to a .txt file. I understand that the coding is basic and easy to understand but just recently this code has decided to not work.

file1 = open("document.txt",'w')

firstname = input("What is your first name?")

secondname = input("what is you second name?")
file1 = open ('document.txt','w')
file1.write (firstname + secondname)

newfile.close()

I am given the following error when running this piece of code

kian
  • 1
  • 1

1 Answers1

0

You have to use raw_input in order to get a string in Python 2. input is evaluating the user input, seeing the variable name which is not defined.

timgeb
  • 76,762
  • 20
  • 123
  • 145