I'm using an input function where I want to convert any spaces in the input to +
's. So for example, if the user inputs iphone 7 black
, I want to convert this to iphone+7+black
.
I'm using an input function where I want to convert any spaces in the input to +
's. So for example, if the user inputs iphone 7 black
, I want to convert this to iphone+7+black
.
Just use replace
:
>>> text = raw_input('Enter text: ')
Enter text: iphone 7 black
>>> text.replace(' ', '+')
'iphone+7+black'