0
How can I find the space between words in a text?
10 Antworten
+ 3
Returns a list with index number of spaces in a text
def space(text):
j=0
l=[]
for i in text:
if i==" ":
l.append(j)
j+=1
return l
+ 1
I didn't knew there was isspace also lol! i would just do
For i in text:
If i!=" ":
print(i)
+ 1
You may find answer in:-
1) http://www.datasciencemadesimple.com/add-spaces-in-JUMP_LINK__&&__python__&&__JUMP_LINK/
2) https://qr.ae/pNynWw
+ 1
def nospaces(x):
print(''.join(i for i in x if i != chr(32)))
0
I want to define a function for it
0
I don't want to use pre-written commands
0
Are you trying to return the count of spaces in a string/text?
0
rodwynnejones
In fact, I want to write a command to return the words of a text without using the split command, so I want to first define a function to find the space between the words.