Skip to content
Advertisement

How to strip only specific parts of a list element in Python

So lets say i have a list, where one element contains an ‘hour-minute-second-tagnumber’, like this:

JavaScript

How do I make this of an element: '103012 TTH-312'?

Can I .strip only specific parts of an element somehow?

Advertisement

Answer

You can limit the number of replace to 2.

JavaScript

Output

JavaScript

If you are trying to do a loop:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement