How to add space to string. example: "Hiwatsup?" or "hi,hello" return "hi hello" or "hi" "hello"
For "hi,hello" you can just replace the "," for a whitespace:
hi = "hi,hello"
print hi.replace(",", " ")
you can also obtain a list of substrings split by a certain character:
print hi.split(',')
but what I really advise doing is looking at the documentation for str:
help(str)
Like this
s = "hi,hello"
t = s.split(',')
print ' '.join(t)
And for the other one
>>> s = "Hiwatsup?"
>>> print s[:2] + ' ' + s[2:]
Hi watsup?
Instead of printing, you can assign it to another variable too.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论