Given a string S. The task is to convert characters of string to lowercase.
Example 1:
Input: S = "ABCddE"
Output: "abcdde"
Explanation: A, B, C and E are converted to
a, b, c and E thus all uppercase characters 
of the string converted to lowercase letter.
Example 2:
Input: S = "LMNOppQQ"
Output: "lmnoppqq"
Explanation: L, M, N, O, and Q are 
converted to l, m, n, o and q thus 
all uppercase characters of the 
string converted to lowercase letter.
Your Task:  
You dont need to read input or print anything. Complete the function toLower() which takes S as input parameter and returns the converted string.
Expected Time Complexity:O(n)
Expected Auxiliary Space: O(1) 
Constraints:
1 <= |S| <= 1000
Input only contains lowercase/uppercase English alphabets.

Source: geeksforgeeks | Difficulty: EASY
Tags: String algorithms

Data structures

Starter code: #User function Template for python3



class Solution:

    def toLower (ob, S):

        # code here 

Solutions:
class Solution:

	def toLower(ob, S):
		return S.lower()


class Solution:

	def toLower(ob, S):
		l = []
		for i in S:
			if ord(i) >= 65 and ord(i) <= 90:
				l.append(chr(ord(i) + 32))
			else:
				l.append(i)
		S = ''.join(l)
		return S


class Solution:

	def toLower(ob, s):
		return s.lower()


class Solution:

	def toLower(ob, S):
		result = ''
		for i in S:
			if i.isupper():
				result += i.lower()
			else:
				result += i
		return result


class Solution:

	def toLower(ob, S):
		newstr = ''
		for char in S:
			if ord('a') >= ord(char):
				newstr += chr(ord(char) + 32)
			else:
				newstr += char
		return newstr


class Solution:

	def toLower(self, S: str) -> str:
		converted_S = S.lower()
		return converted_S


class Solution:

	def toLower(seld, s: str):
		converted_S = S.lower()
		return converted_S


class Solution:

	def toLower(self, S: str) -> str:
		len_s = len(S)
		new_s = ''
		for i in range(len_s):
			if S[i].isupper():
				new_s += S[i].lower()
			else:
				new_s += S[i]
		return new_s


class Solution:

	@staticmethod
	def toLower(S):
		lowercase_string = ''
		for char in S:
			if ord(char) >= 65 and ord(char) <= 90:
				lowercase_char = chr(ord(char) + 32)
			else:
				lowercase_char = char
			lowercase_string += lowercase_char
		return lowercase_string


class Solution:

	def toLower(self, S: str) -> str:
		len_str = len(S)
		for i in range(len_str):
			if S[i].isupper():
				S = S[:i] + S[i].lower() + S[i + 1:]
		return S


class Solution:

	def toLower(ob, s):
		t = ''
		for i in s:
			t += i.lower()
		return t


class Solution:

	def toLower(self, S):
		return S.lower()


class Solution:

	def toLower(ob, S):
		res = ''
		for e in S:
			numb = ord(e)
			if numb >= 65 and numb <= 90:
				numb = numb + 32
			character = chr(numb)
			res = res + character
		return res


class Solution:

	def toLower(ob, S):
		a = ''
		for ele in S:
			if ele.isupper() == True:
				a += ele.swapcase()
			else:
				a += ele
		return a


class Solution:

	def toLower(ob, S):
		opt = ''
		for ltr in range(0, len(S)):
			if ord(S[ltr]) <= 90 and ord(S[ltr]) >= 65:
				n = ord(S[ltr]) + 32
				m = chr(n)
			else:
				m = S[ltr]
			opt += m
		return opt


class Solution:

	def toLower(ob, S):
		return S.casefold()


class Solution:

	def toLower(ob, S):
		j = ''
		for i in range(len(S)):
			if ord(S[i]) >= 65 and ord(S[i]) <= 90:
				j = chr(ord(S[i]) + 32)
				if i == len(S):
					S = S[:i] + j
				else:
					S = S[:i] + j + S[i + 1:]
		return S


class Solution:

	def toLower(ob, S):
		S = ''.join((e for e in S.lower() if e.isalpha()))
		return S