-
-
Save renzon/e2da1c50d914909427f51d4993e94e87 to your computer and use it in GitHub Desktop.
String -> N iterations -> String created by dubirajara1 - https://repl.it/@dubirajara1/String-greater-N-iterations-greater-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
from itertools import chain | |
def string_n_string(s, n): | |
for _ in range(n): | |
even = (char for i, char in enumerate(s) if i % 2 == 0) | |
odd = (char for i, char in enumerate(s) if i % 2 != 0) | |
s = ''.join(chain(even , odd)) | |
return s | |
assert string_n_string("Wow Example!", 1) == "WwEapeo xml!" # testcase | |
assert string_n_string("qwertyuio", 2) == "qtorieuwy" # testcase |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment