0

I am trying to add user input using the raw_input function to string url_orig. I am attempting to replace the spaces with +'s to make a 'google search'. the replace function works fine in IDE but not when I excecute the program. Any help will be appreciated

url_orig = 'http://www.google.com/search?hl=en&q='
url_add1 = ''
s.replace(' ', '+')
print s
3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by woooee
0

I am trying to add user input using the raw_input function to string url_orig. I am attempting to replace the spaces with +'s to make a 'google search'. the replace function works fine in IDE but not when I excecute the program. Any help will be appreciated

url_orig = 'http://www.google.com/search?hl=en&q='
url_add1 = ''
s.replace(' ', '+')
print s

Erm. Do you have a GUI? If so use a text box. If not, then you'll call the function from command line, right? So you can assume they'll enter input at command line. I don't know how to do input otherwise.

I don't see why you want to fiddle with +'s and spaces? The end? Please define your problem more clearly. It would help if you actually, you know, gave us your full code. I have no clue what s is for example.

BTW: unless you pretend you are Opera or Firefox or something, google won't let you perform a search.

Edit: I think I get you. Well you could try:

s = '+'.join((s.split(' ')))

I've never used replace() so I couldn't tell you what's wrong there.

I just tried replace. It works fine for me. I doubt your code worked for you at all, TBH, since you forgot to assign the replacement:
s = s.replace(' ', '+')

0

Add "Solved" or "Ignore This" to the thread title and in a day or two it will be too far down the list to notice.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.