I am trying to replace a list of string into a list of int.
I was given a list looks something like this:
List = ["1 min", "12 min", "721 min"]
And I would like to convert it to something like this:
[1, 12, 721]
My thought is to use for
to loop for every element, i.e.
for i in List:
list[i] = int(i)
But since the time is not constant, it might be 1 digit number, 2 digit or 3... I would love to know if there is a way to modify the element such that whenever there exist a space " " in the element, I would delete the rest of the substring of that string? (E.g. "1 min" becomes "1").