A space separator is default, so you can write

    for r in ranges.split():