Created
November 22, 2022 06:25
-
-
Save mdpabel/50326e5547cfd90f15334039543f4481 to your computer and use it in GitHub Desktop.
Words from string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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