Ad
Algorithms
Logic
Code
Diff
  • def get_nth_words(string, n):
        return " ".join(string.split()[n-1::n]) if n>0 else ""
    • def get_nth_words(string, n):
    • try:
    • if n > 0:
    • return " ".join(string.split(" ")[n-1::n])
    • else:
    • return ""
    • except:
    • return ""
    • return " ".join(string.split()[n-1::n]) if n>0 else ""