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
.
Asked
Active
Viewed 39 times
-5
-
2This is not a "solve for me" website. Provide us with some code and what problem you face. – m0nhawk Apr 17 '17 at 15:49
-
"IPhone 6 S".replace(" ", "+") - read the [documentation!](https://docs.python.org/3.6/library/stdtypes.html#string-methods) – Thierry Lathuille Apr 17 '17 at 15:53
1 Answers
0
Just use replace
:
>>> text = raw_input('Enter text: ')
Enter text: iphone 7 black
>>> text.replace(' ', '+')
'iphone+7+black'

lch
- 2,028
- 2
- 25
- 46
-
Thank you so much - that worked perfectly! Sorry for asking such a dumb question - I'm just working on my first ever coding project and am not familiar with a lot of the basic functions that are out there. – Linnie Apr 17 '17 at 16:00
-