+ Post New Thread
Results 1 to 3 of 3
Coding Thread, Python GUI/Codecademy Weblab error in Coding and Web Development; Hi all, Hopefully someone out there will be able to point me in the right direction on this... Disclaimer: I ...
  1. #1

    Join Date
    Feb 2009
    Location
    Hampshire
    Posts
    71
    Thank Post
    12
    Thanked 4 Times in 4 Posts
    Rep Power
    12

    Python GUI/Codecademy Weblab error

    Hi all,

    Hopefully someone out there will be able to point me in the right direction on this... Disclaimer: I know nothing about Python.

    Initial proposal was to set up VMs running Python, but instead we've opted to use the Codecademy Labs online. Not a problem for most stuff, until one of our ICT teachers reported the code below:

    firstname = input("Please enter your first name: ")
    surname = input("Please enter your last name: ")
    county = input("Please enter your county: ")
    print("Hello {0} {1}. You live in the county of: {2}.".format(firstname,surname,county))


    This works fine when run from an installed Python GUI. So when I run, it prompts me to enter my firstname, surname etc. And you can see what it spits out in the last line of code.

    But when trying to run on the Codecademy website it returns the following:

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "<string>", line 1, in <module>
    NameError: name 'Matt' is not defined


    Anyone got any ideas on this? Many thanks in advance!

  2. #2

    Join Date
    Dec 2012
    Location
    Skipton, North Yorkshire
    Posts
    27
    Thank Post
    11
    Thanked 3 Times in 3 Posts
    Rep Power
    15
    I'm not a regular python coder but I think it may be to do with differences in the version of python.

    As I understand it in Python 2.x you need to use raw_input() to capture a string, because input() will capture then eval the input as Python code (I'm assuming this behaviour changed at some point if you're saying it works for you locally). So essentially what you were doing equates to:

    Code:
    firstname = Matt
    and obviously there's no such object `Matt`!
    Last edited by mikecampbell; 24th February 2014 at 03:41 PM.

  3. #3

    Join Date
    Feb 2009
    Location
    Hampshire
    Posts
    71
    Thank Post
    12
    Thanked 4 Times in 4 Posts
    Rep Power
    12
    Thanks for your reply. Makes some sense since the Web Lab runs v.2.7 and the download I installed this morning was 3.something.

    If anyone else out there has any other thoughts i'm all ears! Google searched this particular error earlier and got more results than humanly possible to sift through...

SHARE:
+ Post New Thread

Similar Threads

  1. Python GUI
    By mrbios in forum How do you do....it?
    Replies: 2
    Last Post: 22nd November 2013, 11:34 AM
  2. Python GUI dev?
    By localzuk in forum Coding
    Replies: 10
    Last Post: 16th November 2012, 01:02 PM
  3. liberum and asp error message
    By russdev in forum Windows
    Replies: 2
    Last Post: 25th November 2005, 01:46 PM
  4. Adduser.conf parse errors
    By ChrisH in forum *nix
    Replies: 4
    Last Post: 18th November 2005, 11:10 AM
  5. Kerberos error - All policies disappeared
    By ajbritton in forum Windows
    Replies: 13
    Last Post: 2nd November 2005, 02:13 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •