Just started learning list comprehension in Python and confusing a lot.
My code is:
    no_duplicates_list = []    
    for url in sorted_temp_list:
        found = False
        for index, url_for_comparing in enumerate(sorted_temp_list):
            if url in url_for_comparing and url != url_for_comparing:
                sorted_temp_list[index] = url
                found = True
        if found is True:
            no_duplicates_list.append(url)
    return no_duplicates_list
Already spent huge time with it but can't understand how to add boolean variable inside and variable assignment.
More details where I use it: if a url is parent, all other urls with the the first url as the prefix should be removed. Here is an example
- aaaccc.com/a
- aaaccc.com/a/b
- aaaccc.com/a/b/c
- aaaccc.com/a/c
- aaaccc.com/a/d
- aaaccc.com/a/e
- aaaccc.com/b/bc
- aaaccc.com/b/bc/a
- aaaccc.com/b/bc/b
In the above list since url 1 is in the list, rows 2 through 6 will inherit that reputation. Similarly, due to row 7, rows 8 and 9 also not necessary as they will inherit reputation from 7.
