Given a string of digits 0 – 9. The task is to count the number of substrings which when converting into integer form an even number.
Example 1:
Input : s = "1234".
Output : 6
Explanation: "2", "4", "12", "34", "234",
"1234" are 6 substring which are even.
Example 2:
Input : s = "154".
Output : 3
Explanation: "154", "54", "4" are the 
even substrings.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function evenNumSubstring() which takes the string as inputs and returns the count of even substring.
Expected Time Complexity: O(|S|)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ |S| ≤ 10^{5}

Difficulty: EASY
Tags: String algorithms

Data structures

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

Starter code:
#User function Template for python3



class Solution:



    def evenNumSubstring(self, S):

        # code here

Solutions:
class Solution:

	def evenNumSubstring(self, S):
		count = 0
		for i in range(len(S)):
			if int(S[i]) % 2 == 0:
				count += i + 1
		return count


class Solution:

	def evenNumSubstring(self, s):
		l = []
		for i in range(len(s)):
			if int(s[i]) % 2 == 0:
				l.append(i + 1)
		return sum(l)


class Solution:

	def evenNumSubstring(self, s):
		count = 0
		for i in range(0, len(s), 1):
			temp = ord(s[i]) - ord('0')
			if temp % 2 == 0:
				count += i + 1
		return count


class Solution:

	def evenNumSubstring(self, S):
		count = 0
		for (i, char) in enumerate(S):
			if int(char) % 2 == 0:
				count += i + 1
		return count


class Solution:

	def evenNumSubstring(self, S):
		l1 = []
		count = 0
		for i in S:
			if i != ' ' or '':
				l1.append(int(i))
		for i in range(len(l1)):
			if l1[i] % 2 == 0:
				count += i + 1
		return count
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		S = input()
		solObj = Solution()
		print(solObj.evenNumSubstring(S))


class Solution:

	def evenNumSubstring(self, S):
		c = 0
		for i in range(len(S)):
			if S[i] == '0' or S[i] == '2' or S[i] == '4' or (S[i] == '6') or (S[i] == '8'):
				c += i + 1
		return c
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		S = input()
		solObj = Solution()
		print(solObj.evenNumSubstring(S))


class Solution:

	def evenNumSubstring(self, S):
		count = 0
		for i in range(len(S)):
			if S[i] == '0' or S[i] == '2' or S[i] == '4' or (S[i] == '6') or (S[i] == '8'):
				count += i + 1
		return count


class Solution:

	def evenNumSubstring(self, S):
		ans = 0
		n = len(S)
		i = n - 1
		while i >= 0:
			v = int(S[i]) - 0
			if v % 2 == 0:
				ans += i + 1
			i -= 1
		return ans


class Solution:

	def evenNumSubstring(self, S):
		n = len(S)
		c = 0
		for i in range(0, n, 1):
			t = ord(S[i]) - ord('0')
			if t % 2 == 0:
				c += i + 1
		return c


class Solution:

	def evenNumSubstring(self, S):
		r = list(S)
		k = 0
		if int(r[len(S) - 1]) % 2 == 0:
			k = k + 1
		sum = k
		for i in range(len(S) - 2, -1, -1):
			if int(r[i]) % 2 == 0:
				k = k + 1
			sum = sum + k
		return sum


class Solution:

	def evenNumSubstring(self, S):
		n = len(S)
		l = n
		cnt = 0
		for i in range(n - 1, -1, -1):
			if int(S[i]) % 2 == 0 or int(S[i]) == 0:
				cnt = cnt + i + 1
		return cnt