Avatar ·

How to trim the line in Python to the desired symbol from the end

📁 строка, python, работа

Given line:

  a =      

how you can cut the string from the end to' - ', so that It tued out:

       

earlier, when there was only one ' -' made through .split (' -') And he removed the last element under the index [1], but as soon as the lines with two met ' -' this ceased to work correctly. Or it can also be through. Split (' -'), but not to remove specifically [1], but simply the last element in the resulting list. Who knows how to do it? Tell me, please.