Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Says Name Error: global name 'string' is not defined. How do I correct?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Randy Armstrong  
View profile  
 More options Oct 28 2012, 8:04 pm
From: Randy Armstrong <affinit...@gmail.com>
Date: Sun, 28 Oct 2012 17:04:39 -0700 (PDT)
Local: Sun, Oct 28 2012 8:04 pm
Subject: Says Name Error: global name 'string' is not defined. How do I correct?

def main():

    print "This program converts a sequence of ASCII numbers into"
    print "the string of text that it represents."
    print

    # get the message to encode

    instring = raw_input("Please enter the ASCII-encoded messages: ")
    #loop through each substring and build ASCII message

    message = ""
    for numStr in string.split(inString):
        asciinum = eval(numstr)    # convert digits to a number
        message = message + chr(asciinum)    # append character to message
    print  "The decoded message is: ", message

main()


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy Milne  
View profile  
 More options Oct 28 2012, 10:29 pm
From: Andy Milne <gspi...@gmail.com>
Date: Sun, 28 Oct 2012 19:29:48 -0700
Local: Sun, Oct 28 2012 10:29 pm
Subject: Re: Says Name Error: global name 'string' is not defined. How do I correct?

Replace:

> string.split

With:

> instring.split

On Oct 28, 2012, at 5:04 PM, Randy Armstrong <affinit...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Randy Armstrong  
View profile  
 More options Oct 28 2012, 10:46 pm
From: Randy Armstrong <affinit...@gmail.com>
Date: Sun, 28 Oct 2012 22:46:38 -0400
Local: Sun, Oct 28 2012 10:46 pm
Subject: Re: Says Name Error: global name 'string' is not defined. How do I correct?

not working, are you able to get it to work?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy Milne  
View profile  
 More options Oct 28 2012, 11:54 pm
From: Andy Milne <gspi...@gmail.com>
Date: Sun, 28 Oct 2012 20:54:48 -0700
Local: Sun, Oct 28 2012 11:54 pm
Subject: Re: Says Name Error: global name 'string' is not defined. How do I correct?

Fixed the error, but doesn't run as you expect?

What delimiter are you expecting in the input?

Whatever the delimiter is, pass it as the parameter to split.

On Oct 28, 2012, at 7:46 PM, Randy Armstrong <affinit...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Randy Armstrong  
View profile  
 More options Oct 29 2012, 12:40 am
From: Randy Armstrong <affinit...@gmail.com>
Date: Mon, 29 Oct 2012 00:40:33 -0400
Local: Mon, Oct 29 2012 12:40 am
Subject: Re: Says Name Error: global name 'string' is not defined. How do I correct?

got these programs out of book python programming introduction to computer
science 2004 which could be my problem. The first program: text2numbers.py
works fine but it's sister program- numbers2text.py take the numbers and
turns them back into legible text. and ive done it exactly as the book
shows so thats why im puzzled and thinking its just out of date code. Im in
my first year with this so if that gives you an indication as to where im
at here.Thanks for helping Im just glad someone replied!

Randy


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »