Created
October 5, 2016 13:45
-
-
Save ihfazhillah/c4341e9909238f66e4c87dfbfeeaf310 to your computer and use it in GitHub Desktop.
menemukan jumlah bab didalam string dibawah ini | s = "sldjfalskdfjbabababksjdfalkj"| expected = 3
This file contains hidden or 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
""" | |
latihan algoritma dasar... | |
menemukan jumlah bab didalam string dibawah ini | |
s = "sldjfalskdfjbabababksjdfalkj" | |
expected = 3 | |
""" | |
S = "sldjfalskdfjbabababksjdfalkj" | |
count_bab = 0 | |
for i, char in enumerate(S): | |
if char == "b": | |
S_2 = S[i:] | |
if "bab" in S_2: | |
count_bab += 1 | |
assert count_bab == 3 | |
print("suksess...!!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment