Given a string S consisting of upper/lower-case alphabets and empty space characters ‘ ‘. The string may contain spaces at the end. You will have return the length of last word which consists of alphabets only.
Example 1:
Input:
S = "Geeks for Geeks"
Output: 5
Explanation: The last word is "Geeks" 
             of length 5.
Example 2:
Input:
S = "Start Coding Here "
Output: 4
Explanation: The last word is "Here" of
             length 4.
Your Task:
You don't need to read input or print anything.Your task is to complete the function findLength() which takes a single argument(string S) and returns the length of last word of the string.
Expected Time Complexity: O(|S|).
Expected Auxiliary Space: O(1).
Constraints:
1<=|S|<=100
|S| denotes the length of the string S.

Difficulty: EASY
Tags: String algorithms

Data structures
Skill types: Data structures
Expected Time Complexity: O(|S|).
Expected Auxiliary Space: O(1).

Starter code:
#User function Template for python3

class Solution:

    def findLength(self, s):
        # code here

Solutions:
class Solution:

	def findLength(self, s):
		n = len(s)
		count = 0
		for i in range(n - 1, -1, -1):
			if s[i] == ' ' and count > 0:
				return count
			elif s[i] != ' ':
				count += 1
		return count


class Solution:

	def findLength(self, s):
		return len(s.split()[-1])


class Solution:

	def findLength(self, s):
		s1 = s.rstrip()
		s2 = s1.split(' ')
		for i in s2:
			if i.isalpha():
				m = s2[-1]
		return len(m)


class Solution:

	def findLength(self, s):
		l1 = s.split()
		lng = len(l1)
		k = l1[lng - 1]
		return len(k)


class Solution:

	def findLength(self, s):
		b = s.split()
		for i in b:
			if i == ' ':
				b.remove(i)
		return len(b[-1])


class Solution:

	def findLength(self, s):
		(i, length) = (len(s) - 1, 0)
		while s[i] == ' ':
			i -= 1
		while s[i] != ' ' and i >= 0:
			length += 1
			i -= 1
		return length


class Solution:

	def findLength(self, s):
		l = 0
		x = s.strip()
		for i in range(len(x)):
			if x[i] == ' ':
				l = 0
			else:
				l += 1
		return l


class Solution:

	def findLength(self, s):
		S = s.split()
		a = ''
		for v in S[-1]:
			a += v
		return len(a)


class Solution:

	def findLength(self, s):
		s1 = s.split()
		ans = len(s1[-1])
		return ans


class Solution:

	def findLength(self, s):
		s1 = ''
		i = -1
		while s[i] == ' ':
			i = i - 1
		for j in range(i, -(len(s) + 1), -1):
			if s[j] == ' ':
				break
			s1 += s[j]
		return len(s1)


class Solution:

	def findLength(self, s):
		m = s.rstrip()
		p = m.split(' ')
		return len(p[-1])


class Solution:

	def findLength(self, s):
		while s and s[-1] == ' ':
			s = s[:-1]
		c = 0
		while s and s[-1] != ' ':
			s = s[:-1]
			c += 1
		return c


class Solution:

	def findLength(self, s):
		(left, res) = (len(s) - 1, 0)
		while s[left] == ' ':
			left -= 1
		for i in range(len(s) - 1, -1, -1):
			if s[left] != ' ':
				res += 1
				left -= 1
		return res


class Solution:

	def findLength(self, s):
		l = s.split()
		for i in l:
			return len(l[-1])


class Solution:

	def findLength(self, s):
		li = s.split()
		ans = len(li[-1])
		return ans


class Solution:

	def findLength(self, s):
		s = s.rstrip()
		x = 0
		for i in range(len(s) - 1, -1, -1):
			if s[i] == ' ':
				break
			x += 1
		return x


class Solution:

	def findLength(self, s):
		k = s.split()
		m = k[-1]
		return len(m)


class Solution:

	def findLength(self, s):
		a = s.rstrip()
		b = a.split(' ')
		for i in b:
			if i.isalpha():
				op = b[-1]
		return len(op)


class Solution:

	def findLength(self, s):
		a = s.split()
		if a[-1].isalpha():
			return len(a[-1])


class Solution:

	def findLength(self, s):
		a = list(s.split())
		return len(a[-1])


class Solution:

	def findLength(self, s):
		u = s.rstrip()
		i = u.split(' ')
		for h in i:
			m = i[-1]
		return len(m)


class Solution:

	def findLength(self, s):
		s1 = s.rstrip()
		s = ' ' + s1
		x = 0
		for i in s[::-1]:
			if i != ' ':
				x += 1
			else:
				break
		return x


class Solution:

	def findLength(self, s):
		return len(s.split()[-1])
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		s = input()
		solObj = Solution()


class Solution:

	def findLength(self, s):
		k = s.rstrip()
		lst = k.split(' ')
		return len(lst[-1])


class Solution:

	def findLength(self, s):
		sentence = s.strip()
		word_list = sentence.split(' ')
		return len(word_list[-1])


class Solution:

	def findLength(self, s):
		ans = s.split()
		an = len(ans[-1])
		return an


class Solution:

	def findLength(self, s):
		if s != '':
			s1 = s.split()
			return len(s1[-1])
		else:
			return 0


class Solution:

	def findLength(self, S):
		S = S.split()
		return len(S[-1])


class Solution:

	def findLength(self, s):
		arr = list(map(str, s.split()))
		a = arr[-1]
		return len(a)


class Solution:

	def findLength(self, s):
		p = [*zip((len(s) - i for (i, c) in enumerate(reversed(s)) if c != ' '), [0]), (0, 0)][0][0]
		return p - s.rfind(' ', None, p) - 1


class Solution:

	def findLength(self, s):
		arr = s.split()
		n = len(arr)
		return len(arr[n - 1])


class Solution:

	def findLength(self, s):
		s1 = s.rstrip()
		a = s1.split(' ')
		b = a[-1]
		return len(b)


class Solution:

	def findLength(self, s):
		s = s.split()
		d = len(s)
		k = len(s[d - 1])
		return k


class Solution:

	def findLength(self, s):
		count = 0
		tempcount = 0
		for i in s:
			if i != ' ':
				tempcount += 1
			else:
				count = tempcount
				tempcount = 0
		if s[-1] != ' ':
			count = tempcount
		return count


class Solution:

	def findLength(self, s):
		word = s.split()
		last = word[-1]
		return len(last)


class Solution:

	def findLength(self, s):
		l = s.split()
		x = l[len(l) - 1]
		return len(x)


class Solution:

	def findLength(self, s):
		count = 0
		i = len(s) - 1
		while i >= 0:
			if s[i] != ' ':
				count += 1
			elif count != 0:
				break
			i -= 1
		return count


class Solution:

	def findLength(self, s):
		m = []
		for i in s.split():
			m.append(i)
		return len(m[-1])


class Solution:

	def findLength(self, s):
		m = -1
		s = s.title()
		s = s.replace(' ', '')
		for i in range(len(s)):
			if s[i].isupper() == 1:
				if i >= m:
					m = i
		n = len(s)
		return n - m


class Solution:

	def findLength(self, s):
		s = s.strip()
		arr = s.split(' ')
		ans = len(arr[len(arr) - 1])
		return ans


class Solution:

	def findLength(self, s):
		lis = s.split()
		for i in range(len(lis)):
			if lis[-i].isalpha():
				return len(lis[-1])
				break


class Solution:

	def findLength(self, x):
		s1 = s.rstrip()
		s2 = s1.split(' ')
		m = s2[-1]
		return len(m)


class Solution:

	def findLength(self, s):
		b = s.strip()
		count = 0
		i = len(b) - 1
		while i >= 0:
			if b[i] != ' ':
				count = count + 1
				i = i - 1
			else:
				break
		return count


class Solution:

	def findLength(self, s):
		list_a = s.split()
		for i in range(1, len(list_a) + 1):
			if list_a[-i] != '':
				return len(list_a[-i])