title: Python NameError - Name not defined after User Input
body: <p>All,</p>
  
  <p>I have the following code:</p>
  
  <pre><code>val1 = str(input("Enter string element 1/3: "))
  val2 = int(input("Enter integer element 2/3: "))
  val3 = float(input("Enter float element 3/3: "))
  
  lst = [val1, val2, val3]
  tpl = (val1, val2, val3)
  dict = {"First element: ":val1, "Second element: ":val2, "Third element: ":val3}
  
  print("/n")
  print("Here is your list: ", lst)
  print("Here is your tuple: ", tpl)
  print("Here is your dictionary ", dict)
  
  print("/n")
  val4 = input("Add a new str list element: ")
  lst.append(val4)
  print("Here is your new list ", lst) 
  </code></pre>
  
  <p>But i seem to get this return:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/Python27/Test2", line 1, in &lt;module&gt;
      val1 = str(input("Enter string element 1/3: "))
    File "&lt;string&gt;", line 1, in &lt;module&gt;
  NameError: name 'test' is not defined
  </code></pre>
  
  <p>However, int and float both work - so why doesn't string? It's saying that 'test' isn't defined, but i thought it because defined after the user inputted the word?</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Regards,</p>