Raw Input Question

H

hokiegal99

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!!!
 
M

mackstann

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)
 
E

Erik Max Francis

hokiegal99 said:
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
 
H

hokiegal99

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!!!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top