Given a Python line like this:
location_in = 'London, Greater London, England, United Kingdom'
I would like to convert it to a list like this:
location_out = ['London, Greater London, England, United Kingdom', 'Greater London, England, United Kingdom', 'England, United Kingdom', 'United Kingdom']
In other words, if you set a comma string ( location_in
), I would like to copy it to a list ( location_out
) and gradually split it by deleting the first word / phrase each time.
I am new to Python. Any ideas on a good way to write this? Thanks.
Federico
source share