Raw Input Question

Discussion in 'Python' started by hokiegal99, Aug 27, 2003.

  1. hokiegal99

    hokiegal99 Guest

    How can I pass the content of one varible into raw_input? See below for
    what I'm trying to do:

    XXX = raw_input("1. Enter the string that you'd like to find: ")
    y = raw_input("2. Enter the string that you'd like to replace XXX with: ")

    I'm trying to pass x into y. I tried the "Enter the string that you'd
    like to replace", XXX, "with:" approach, but Pyhton told me that I could
    only pass 1 argument, no more.

    Thanks!!!
    hokiegal99, Aug 27, 2003
    #1
    1. Advertising

  2. hokiegal99

    mackstann Guest

    On Tue, Aug 26, 2003 at 10:33:36PM -0400, hokiegal99 wrote:
    > How can I pass the content of one varible into raw_input? See below for
    > what I'm trying to do:
    >
    > XXX = raw_input("1. Enter the string that you'd like to find: ")
    > y = raw_input("2. Enter the string that you'd like to replace XXX with: ")
    >
    > I'm trying to pass x into y. I tried the "Enter the string that you'd
    > like to replace", XXX, "with:" approach, but Pyhton told me that I could
    > only pass 1 argument, no more.


    Ah, you are confusing print's behavior for general string concatenation.
    I believe what you want to do is:

    y = raw_input("2. Enter the string that you'd like to replace "+XXX+" with:")

    or

    y = raw_input("2. Enter the string that you'd like to replace %s with:" % XXX)

    --
    m a c k s t a n n mack @ incise.org http://incise.org
    As the poet said, "Only God can make a tree" -- probably because it's
    so hard to figure out how to get the bark on.
    -- Woody Allen
    mackstann, Aug 27, 2003
    #2
    1. Advertising

  3. hokiegal99 wrote:

    > How can I pass the content of one varible into raw_input? See below
    > for
    > what I'm trying to do:
    >
    > XXX = raw_input("1. Enter the string that you'd like to find: ")
    > y = raw_input("2. Enter the string that you'd like to replace XXX
    > with: ")
    >
    > I'm trying to pass x into y. I tried the "Enter the string that you'd
    > like to replace", XXX, "with:" approach, but Pyhton told me that I
    > could
    > only pass 1 argument, no more.


    raw_input takes a string, and a string like any other. You can build
    the string yourself:

    "Enter the string to replace " + XXX + " with:"

    or

    "Enter the string to replace %s with:" % XXX

    --
    Erik Max Francis && && http://www.alcyone.com/max/
    __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
    / \ There never was a good war or a bad peace.
    \__/ Benjamin Franklin
    Erik Max Francis, Aug 27, 2003
    #3
  4. hokiegal99

    hokiegal99 Guest

    This one makes more sense to me so I used it, it works great:

    "Enter the string to replace %s with:" % XXX

    Thank you for your help!!!


    Erik Max Francis wrote:
    > hokiegal99 wrote:
    >
    >
    >>How can I pass the content of one varible into raw_input? See below
    >>for
    >>what I'm trying to do:
    >>
    >>XXX = raw_input("1. Enter the string that you'd like to find: ")
    >>y = raw_input("2. Enter the string that you'd like to replace XXX
    >>with: ")
    >>
    >>I'm trying to pass x into y. I tried the "Enter the string that you'd
    >>like to replace", XXX, "with:" approach, but Pyhton told me that I
    >>could
    >>only pass 1 argument, no more.

    >
    >
    > raw_input takes a string, and a string like any other. You can build
    > the string yourself:
    >
    > "Enter the string to replace " + XXX + " with:"
    >
    > or
    >
    > "Enter the string to replace %s with:" % XXX
    >
    hokiegal99, Aug 27, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tony Meyer

    RE: Raw Input Question

    Tony Meyer, Aug 27, 2003, in forum: Python
    Replies:
    1
    Views:
    526
    hokiegal99
    Aug 27, 2003
  2. Noah

    raw audio input on Windows

    Noah, Jan 27, 2004, in forum: Python
    Replies:
    1
    Views:
    471
    Kevin Dahlhausen
    Jan 28, 2004
  3. Johannes Graumann

    Path completion in 'raw-input'?

    Johannes Graumann, Mar 1, 2006, in forum: Python
    Replies:
    1
    Views:
    301
    Mc Osten
    Mar 1, 2006
  4. utabintarbo

    Raw strings as input from File?

    utabintarbo, Nov 24, 2009, in forum: Python
    Replies:
    11
    Views:
    586
    Dave Angel
    Dec 2, 2009
  5. Replies:
    1
    Views:
    138
    Charles Calvert
    Mar 29, 2008
Loading...

Share This Page