def replace_string_2(str, true_length):
    """
    Given a string and a true length of the string, replace all spaces with %20.
    Be careful with the spaces that comes after the last character. 
    
    Solution: Count the spaces in the string[:true_length] and add 2*count to the true_length...
    ...when returning the string.
    """

    space_count = 0
    for char in str[:true_length]:
        if char == ' ':
            space_count += 1 

    str_2 = str.replace(' ', '%20')
    return str_2[:true_length + space_count * 2]