I split a very long string separated by semicolons and I want to know how many split items are there?
I recall that this has to do with lists and there is a method in python that tells you how many are in that list. I couldn’t remember the method for it.
Thanks!
You could get the length of the list of items after splitting:
Alternatively, count the number of semicolons and add one:
The latter is probably faster if you don’t need to know what the items are, but only how many items there are.
lenis a function that returns the number of items in a list. Strings have a method calledsplitthat splits a string on a delimeter. They also have a method calledcountthat counts the number of non-overlapping instances of a substring.