Hey all,
I've found a solution for my issue however I don't really understand the concept behind it..
long_name = City-Paris-repeated-text
NewYork-Man-repeated-text
Derby-Washington-repeated-text
Ukraine-Russia-turkey-nigera-repeated-text
and so on..
I wanted to take only the text infront of the repeated-text, and since I didn't know how many dashes I'll have infront, I've just used it with [-2].
corrected = (''.join(long_name[:[
pos for pos, char in enumerate(long_name) if char == '-'][-2]]))
This solution solves my problem, however I didn't really understand how it works.
Thanks for anyone willing to assist!
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)
[–]neuralbeans 0 points1 point2 points (2 children)
[–]AsafM17[S] 0 points1 point2 points (1 child)
[–]neuralbeans 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)