dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
1.7 KiB
1.7 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 68af0687ef34c76c28ffa54b | Challenge 32: Reverse Sentence | 29 | challenge-32 |
--description--
Given a string of words, return a new string with the words in reverse order. For example, the first word should be at the end of the returned string, and the last word should be at the beginning of the returned string.
- In the given string, words can be separated by one or more spaces.
- The returned string should only have one space between words.
--hints--
reverse_sentence("world hello") should return "hello world".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(reverse_sentence("world hello"), "hello world")`)
}})
reverse_sentence("push commit git") should return "git commit push".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(reverse_sentence("push commit git"), "git commit push")`)
}})
reverse_sentence("npm install apt sudo") should return "sudo apt install npm".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(reverse_sentence("npm install apt sudo"), "sudo apt install npm")`)
}})
reverse_sentence("import default function export") should return "export function default import".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(reverse_sentence("import default function export"), "export function default import")`)
}})
--seed--
--seed-contents--
def reverse_sentence(sentence):
return sentence
--solutions--
def reverse_sentence(sentence):
return " ".join(sentence.split()[::-1])