Given a string S, the task is to change the complete string to Uppercase or Lowercase depending upon the case for the first character.
Example 1:
Input:
S = "abCD"
Output: abcd
Explanation: The first letter (a) is 
lowercase. Hence, the complete string
is made lowercase.
Ã¢â¬â¹Example 2:
Input: 
S = "Abcd"
Output: ABCD
Explanation: The first letter (A) is
uppercase. Hence, the complete string
is made uppercase.
Your Task:
You don't need to read input or print anything. Your task is to complete the function modify() which takes the string S as input and returns the resultant string with stated modifications.
Expected Time Complexity: O(|S|).
Expected Auxiliary Space: O(1) for C++ and O(|S|) for output in Java/Python.
Constraints:
1<=|S|<=10^{4}

Difficulty: EASY
Tags: String algorithms

Data structures
Skill types: Data structures
Expected Time Complexity: O(|S|).
Expected Auxiliary Space: O(1) for C++ and O(|S|) for output in Java/Python.

Starter code:
#User function Template for python3


class Solution:
    def modify(self, s):
        # code here

Solutions:
class Solution:

	def modify(self, s):
		if s[0].islower():
			return s.lower()
		return s.upper()


class Solution:

	def modify(self, s):
		ls = list(s)
		upper = False
		if s[0].isupper():
			upper = True
		s = ''
		if upper:
			for e in ls:
				s = s + e.upper()
		else:
			for e in ls:
				s = s + e.lower()
		return s


class Solution:

	def modify(self, s):
		i = 0
		if s[i] >= 'a' and s[i] <= 'z':
			return s.lower()
		else:
			return s.upper()


class Solution:

	def modify(self, s):
		for i in s:
			if s[0].islower():
				return s.lower()
		return s.upper()


class Solution:

	def modify(self, a):
		if a[0].islower():
			return a.lower()
		else:
			return a.upper()


class Solution:

	def modify(self, s):
		for i in range(len(s)):
			if s[0].isupper() == True:
				return s.upper()
			else:
				return s.lower()


class Solution:

	def modify(self, s):
		if s[0].isupper():
			return s.upper()
		else:
			return s.lower()


class Solution:

	def modify(self, s):
		k = list(map(str, str(s)))
		w = ord(k[0])
		if w >= 65 and w <= 91:
			for i in range(1, len(k)):
				r = ord(k[i])
				if r >= 97 and r <= 122:
					r = r - 32
					k[i] = chr(r)
		elif w >= 97 and w <= 122:
			for i in range(1, len(k)):
				r = ord(k[i])
				if r >= 65 and r <= 91:
					r = r + 32
					k[i] = chr(r)
		m = str(''.join(map(str, k)))
		return m


class Solution:

	def modify(self, s):
		if ord(s[0]) >= 97 and ord(s[0]) <= 122:
			return s.lower()
		else:
			return s.upper()


class Solution:

	def modify(self, s):
		ch = s[0]
		if ch.islower() == 1:
			k = s.lower()
		else:
			k = s.upper()
		return k


class Solution:

	def modify(self, s):
		if s[0].isupper():
			f = 1
		else:
			f = 0
		r = ''
		if f == 1:
			for i in s:
				if i.isupper():
					r = r + i
				else:
					r = r + i.upper()
		else:
			for i in s:
				if i.islower():
					r = r + i
				else:
					r = r + i.lower()
		return r


class Solution:

	def modify(self, s):
		small = False
		big = False
		if s[0] >= 'a' and s[0] <= 'z':
			small = True
		else:
			big = True
		ans = ''
		if small:
			for i in s:
				if i >= 'a' and i <= 'z':
					ans += i
				else:
					p = i.lower()
					ans += p
			return ans
		if big:
			for i in s:
				if i >= 'A' and i <= 'Z':
					ans += i
				else:
					p = i.upper()
					ans += p
			return ans


class Solution:

	def modify(self, s):
		s1 = ''
		p = 0
		if s[p].islower():
			s1 += s.lower()
		else:
			s1 += s.upper()
		return s1


class Solution:

	def modify(self, s):
		if s[0].islower() is True:
			return s.lower()
		else:
			return s.upper()


class Solution:

	def modify(self, s):
		j = str(s)
		if s[0] in set('ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
			ans = j.upper()
			return ans
		else:
			ans = j.lower()
			return ans


class Solution:

	def modify(self, s):
		x = ''
		if s[0].isupper():
			x = ''
			for i in s:
				x += i.upper()
		else:
			x = ''
			for i in s:
				x += i.lower()
		return x


class Solution:

	def modify(self, s):
		a = ''
		if s[0] == s[0].lower():
			return s.lower()
		return s.upper()


class Solution:

	def modify(self, s):
		if 'A' <= s[0] <= 'Z':
			return s.upper()
		else:
			return s.lower()


class Solution:

	def modify(self, s):
		i = 0
		if ord(s[i]) < 97:
			return s.upper()
		else:
			return s.lower()


class Solution:

	def modify(self, s):
		if ord(s[0]) >= 65 and ord(s[0]) <= 90:
			return s.upper()
		else:
			return s.lower()


class Solution:

	def modify(self, s):
		if s[0] >= 'a' and s[0] <= 'z':
			return s.lower()
		elif s[0] >= 'A' and s[0] <= 'Z':
			return s.upper()


class Solution:

	def modify(self, s):
		if s[0] in 'abcdefghijklmnopqrstuvwxyz':
			return s.lower()
		else:
			return s.upper()


class Solution:

	def modify(self, s):
		for i in s:
			if i.islower():
				a = s.lower()
				return a
			else:
				a = s.upper()
				return a


class Solution:

	def modify(self, s):
		x1 = 'abcdefghijklmnopqrstuvwxyz'
		x2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
		p = ''
		if s[0] in x1:
			p = s.lower()
		elif s[0] in x2:
			p = s.upper()
		return p


class Solution:

	def modify(self, s):
		lower = s[0].islower()
		upper = s[0].isupper()
		result = ''
		for i in s:
			if lower:
				result += i.lower()
			else:
				result += i.upper()
		return result