Is there a way to slice a string in which you know the start index while only knowing which value you want to end at in Python?
Question:
I’m writing some code that returns the number of views the top Youtube video has based on the search query. The substring starts at index 101, the problem is that not all video views are listed with the same length. For example, "6.8M views" has a length of 10 while "5B views" has just 8. Is there a way to implement a string slice as shown below?
numOfViews = list[101:ends with "views"]
To be clear, I just need the first occurrence of "views" after index 101.
Answers:
I’m writing some code that returns the number of views the top Youtube video has based on the search query. The substring starts at index 101, the problem is that not all video views are listed with the same length. For example, "6.8M views" has a length of 10 while "5B views" has just 8. Is there a way to implement a string slice as shown below?
numOfViews = list[101:ends with "views"]
To be clear, I just need the first occurrence of "views" after index 101.