Skip to content

Instantly share code, notes, and snippets.

@mdpabel
Created November 22, 2022 06:25
Show Gist options
  • Save mdpabel/50326e5547cfd90f15334039543f4481 to your computer and use it in GitHub Desktop.
Save mdpabel/50326e5547cfd90f15334039543f4481 to your computer and use it in GitHub Desktop.
Words from string
s = " hello bangladesh"
li = []
startIdx = 0
for i in range(len(s)):
if s[i] == " " and s[startIdx] != " ":
li.append(s[startIdx : i])
startIdx = i
elif s[startIdx] == " ":
startIdx = i
li.append(s[startIdx : ])
print(li)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment