# Buggy code
def split_argument(req, short=None, long_=None):
    """Split an argument from a string (finds None if not present).

    Uses -short <arg>, --long <arg>, and --long=arg as permutations.

    returns string, index
    """
    index_entries = []
    if long_:
        long_ = " --{0}".format(long_)
        index_entries.extend(["{0}{1}".format(long_, s) for s in [" ", "="]])
    if short:
        index_entries.append(" -{0} ".format(short))
    index = None
    index_entry = first([entry for entry in index_entries if entry in req])
    if index_entry:
        req, index = req.split(index_entry)
        remaining_line = index.split()
        if len(remaining_line) > 1:
            index, more_req = remaining_line[0], " ".join(remaining_line[1:])
            req = "{0} {1}".format(req, more_req)
    return req, index


# Traceback (ValueError)
Traceback (most recent call last):▉▉▉▉ 0/38 — 00:00:00
File "/Users/user/.pyenv/versions/3.6.5/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/Users/user/.pyenv/versions/3.6.5/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/user/.pyenv/versions/3.6.5/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/user/.pyenv/versions/3.6.5/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/user/.pyenv/versions/3.6.5/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/user/.pyenv/versions/3.6.5/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/user/.pyenv/versions/3.6.5/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/cli.py", line 402, in install
selective_upgrade=selective_upgrade,
File "/Users/user/.pyenv/versions/3.6.5/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/core.py", line 1938, in do_install
requirements_dir=requirements_directory,
File "/Users/user/.pyenv/versions/3.6.5/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/core.py", line 1385, in do_init
requirements_dir=requirements_dir.name,
File "/Users/user/.pyenv/versions/3.6.5/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/core.py", line 803, in do_install_dependencies
dep, extra_index = split_argument(dep, long_='extra-index-url')
File "/Users/user/.pyenv/versions/3.6.5/Python.framework/Versions/3.6/lib/python3.6/site-packages/pipenv/utils.py", line 1320, in split_argument
req, index = req.split(index_entry)
ValueError: too many values to unpack (expected 2)
🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/38 — 00:00:00

# Fixed code
def split_argument(req, short=None, long_=None, num=-1):
    """Split an argument from a string (finds None if not present).

    Uses -short <arg>, --long <arg>, and --long=arg as permutations.

    returns string, index
    """
    index_entries = []
    import re

    if long_:
        index_entries.append("--{0}".format(long_))
    if short:
        index_entries.append("-{0}".format(short))
    match_string = "|".join(index_entries)
    matches = re.findall("(?<=\s)({0})([\s=])(\S+)".format(match_string), req)
    remove_strings = []
    match_values = []
    for match in matches:
        match_values.append(match[-1])
        remove_strings.append("".join(match))
    for string_to_remove in remove_strings:
        req = req.replace(" {0}".format(string_to_remove), "")
    if not match_values:
        return req, None
    if num == 1:
        return req, match_values[0]
    if num == -1:
        return req, match_values
    return req, match_values[:num]