← Back to challenges

Retrieve the Subreddit

PythonHardstringsregex

Instructions

Create a function to extract the name of the subreddit from its URL.

Examples

sub_reddit("https://www.reddit.com/r/funny/") ➞ "funny"

sub_reddit("https://www.reddit.com/r/relationships/") ➞ "relationships"

sub_reddit("https://www.reddit.com/r/mildlyinteresting/") ➞ "mildlyinteresting"

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Potential Friend?