Write function alternateCase which switch every letter in string from upper to lower and from lower to upper.
E.g: Hello World -> hELLO wORLD

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def alternateCase(s):
	

Solutions:
def alternateCase(s):
	return s.swapcase()


alternateCase = str.swapcase


def alternateCase(s):
	return ''.join((c.swapcase() for c in s))


def alternateCase(s):
	res = ''.join([letter.lower() if letter.isupper() else letter.upper() for letter in s])
	return res


def alternateCase(s):
	ret = ''
	for c in s:
		if c.isalpha():
			if c.isupper():
				ret += c.lower()
			else:
				ret += c.upper()
		else:
			ret += c
	return ret


alternateCase = lambda s: '' if not s else f'{s[0].swapcase()}{alternateCase(s[1:])}'


def alternateCase(word):
	return word.swapcase()


def alternateCase(s):
	return ''.join((c.upper() if c.islower() else c.lower() for c in s))


alternateCase = lambda s: ''.join((i.lower() if i.isupper() else i.upper() for i in s))


def alternateCase(s):
	string = ''
	for char in s:
		if char.islower():
			string += char.upper()
		else:
			string += char.lower()
	return string


alternateCase = lambda s: list(type(s).__dict__.values())[44](s)


def alternateCase(s):
	return ''.join([x.lower() if x.isupper() else ' ' if x == ' ' else x.upper() for x in s])


def alternateCase(s):
	if len(s) < 1:
		return s
	res = ''
	for l in s:
		if l.isupper():
			res += l.lower()
		else:
			res += l.upper()
	return res


def alternateCase(s):
	res = list(s)
	count = 0
	for item in s:
		if item.isalpha():
			if item.isupper():
				res[count] = item.lower()
			else:
				res[count] = item.upper()
		count += 1
	return ''.join(res)


def alternateCase(s):
	result = ''
	for letter in s:
		if letter.islower():
			result += letter.upper()
		elif letter.isupper():
			result += letter.lower()
		else:
			result += letter
	return result


def alternateCase(s):
	my_own_swapcase = lambda w: ''.join([l.lower() if l.isupper() else l.upper() if l.islower() else l for l in w])
	return my_own_swapcase(s)


def alternateCase(s):
	return ''.join([ch.swapcase() for ch in s])


def alternateCase(s):
	copy = list(s)
	for i in range(0, len(s)):
		if s[i].isupper():
			copy[i] = s[i].lower()
		elif s[i].islower():
			copy[i] = s[i].upper()
		else:
			continue
	return ''.join(copy)


def alternateCase(s):
	a = s.swapcase()
	return a


def alternateCase(s):
	alt = ''
	for i in range(len(str(s))):
		if s[i].islower():
			alt += s[i].upper()
		else:
			alt += s[i].lower()
	return alt


from string import ascii_lowercase, ascii_uppercase
translation_table = str.maketrans(ascii_lowercase + ascii_uppercase, ascii_uppercase + ascii_lowercase)

def alternateCase(s):
	return s.translate(translation_table)


def alternateCase(s):
	newstring = ''
	count1 = 0
	count2 = 0
	count3 = 0
	for a in s:
		if a.isupper() == True:
			count1 += 1
			newstring += a.lower()
		elif a.islower() == True:
			count2 += 1
			newstring += a.upper()
		elif a.isspace() == True:
			count3 += 1
			newstring += a
	return newstring


def alternateCase(s):
	return ''.join(([i.upper(), i.lower()][i.isupper()] for i in s))


def alternateCase(st):
	string = ''
	for letters in st:
		if letters.isupper():
			string += letters.lower()
		else:
			string += letters.upper()
	return string


def alternateCase(s):
	if s == '':
		return s
	r = ''
	for i in range(len(s)):
		if s[i].islower():
			r += s[i].upper()
		else:
			r += s[i].lower()
	return r


def alternateCase(s):
	result = ''
	for char in s:
		ascii_value = ord(char)
		if 97 <= ascii_value <= 122:
			ascii_value -= 32
		elif 65 <= ascii_value <= 90:
			ascii_value += 32
		result += chr(ascii_value)
	return result


def alternateCase(s):
	l = []
	for i in s:
		if i == ' ' or i == '':
			l.append(i)
		elif i.isupper():
			l.append(i.lower())
		elif i.islower():
			l.append(i.upper())
	return ''.join(l)


def alternateCase(s):
	c = ''
	for i in s:
		if i.isupper():
			c += i.lower()
		elif i.islower():
			c += i.upper()
		else:
			c += ' '
	return c


def alternateCase(s):
	a = ''
	for x in s:
		if x.islower():
			a += x.upper()
		else:
			a += x.lower()
	return a


def alternateCase(s):
	lst = []
	for x in s:
		if x.islower():
			lst.append(x.upper())
		elif x.isupper():
			lst.append(x.lower())
		else:
			lst.append(x)
	x = ''.join(lst)
	return x


def alternateCase(s):
	string = ''
	for i in s:
		if i.isupper():
			i = i.lower()
			string += i
		else:
			i = i.upper()
			string += i
	return string


def alternateCase(s):
	string = ''
	for letter in s:
		if letter == letter.upper():
			letter = letter.lower()
			string = string + letter
		else:
			letter = letter.upper()
			string = string + letter
	return string


def alternateCase(s):
	new = ''
	for i in range(len(s)):
		if s[i].islower():
			new += s[i].upper()
		if s[i].isupper():
			new += s[i].lower()
		if s[i] == ' ':
			new += ' '
	return new


def alternateCase(s):
	myList = []
	for i in s:
		if i.isupper():
			myList.append(i.lower())
		elif i.islower():
			myList.append(i.upper())
		else:
			myList.append(i)
	return ''.join(myList)


def alternateCase(s):
	a = ''
	for x in s:
		if x.isupper():
			a += x.lower()
		elif x.islower():
			a += x.upper()
		elif x == ' ':
			a += ' '
	return a


alternateCase = lambda s: ''.join([x.lower() if x.isupper() else x.upper() for x in s])


def alternateCase(s):
	new_upper = s.upper()
	print(s)
	new_sent = []
	for i in range(0, len(s)):
		if s[i] == ' ':
			print(True)
			new_sent.append(' ')
		elif s[i] != new_upper[i]:
			print('Needs upper')
			new_sent.append(s[i].upper())
		else:
			print('Needs lower')
			new_sent.append(s[i].lower())
	print(new_sent)
	answer = ''.join(new_sent)
	print(answer)
	return answer


def alternateCase(s):
	a = []
	for i in s:
		if i.isupper():
			a.append(i.lower())
		else:
			a.append(i.upper())
	return ''.join(a)


def alternateCase(s=''):
	print(s)
	listl = list(s)
	n = len(s)
	i = 0
	while i < n:
		if s[i].isupper() == True:
			print(s[i])
			letra = s[i].lower()
			print(letra)
			listl[i] = letra
			print(listl)
			s = ''.join(listl)
			print(s)
		elif s[i].islower() == True:
			print(s[i])
			letra = s[i].upper()
			print(letra)
			listl[i] = letra
			print(listl)
			s = ''.join(listl)
			print(s)
		i += 1
	return s


def alternateCase(s):
	k = ''
	for x in s:
		if x in 'qwertyuioplkjhgfdsazxcvbnm':
			k = k + x.upper()
		elif x in 'QWERTYUIOPASDFGHJKLZXCVBNM':
			k = k + x.lower()
		else:
			k = k + x
	return k


def alternateCase(s):
	w = ''
	for i in s:
		if i.isupper() == True:
			w += i.lower()
		else:
			w += i.upper()
	return w


def alternateCase(string):
	res = ''
	for char in string:
		if char.lower() == char:
			res += char.upper()
		else:
			res += char.lower()
	return res


def alternateCase(s):
	listW = list(s)
	for i in range(len(listW)):
		if listW[i].islower():
			listW[i] = listW[i].upper()
		elif listW[i].isupper():
			listW[i] = listW[i].lower()
	return ''.join(listW)


def alternateCase(s):
	return ''.join([char.swapcase() for char in s])


def alternateCase(s):
	s = list(s)
	for x in range(len(s)):
		if s[x] == s[x].upper():
			s[x] = s[x].lower()
		else:
			s[x] = s[x].upper()
	return ''.join(s)


def alternateCase(s=''):
	msg = ''
	if s == '':
		return ''
	for i in s:
		if i.islower():
			msg = msg + str(i.upper())
		elif i.isupper():
			msg = msg + str(i.lower())
		else:
			msg = msg + str(i)
	return msg


def alternateCase(s):
	s = str(s)
	ergebnis = ''
	for letter in s:
		if letter.isupper():
			ergebnis += letter.lower()
		else:
			ergebnis += letter.upper()
	return ergebnis


def alternateCase(s):
	news = []
	for i in range(len(s)):
		if s[i].islower():
			news.append(s[i].upper())
		else:
			news += s[i].lower()
	return ''.join(news)


def alternateCase(s):
	res = ''
	for c in s:
		if c.isupper():
			res += c.lower()
		else:
			res += c.upper()
	return res


def alternateCase(s):
	ret = ''
	for x in s:
		if x == x.upper():
			ret += x.lower()
		else:
			ret += x.upper()
	return ret


def alternateCase(s):
	n_s = ''
	if s.isspace():
		return s
	for i in s:
		if i.isupper():
			n_s += i.lower()
		elif i.lower():
			n_s += i.upper()
		else:
			n_s += i
	return n_s


def alternateCase(s):
	new_s = ''
	for ltr in s:
		if ltr.lower() == ltr:
			ltr = ltr.upper()
		else:
			ltr = ltr.lower()
		new_s += ltr
	return new_s


def alternateCase(s):
	new_string = ''
	for a in s:
		if a.isupper() == True:
			new_string += a.lower()
		elif a.islower() == True:
			new_string += a.upper()
		elif a.isspace() == True:
			new_string += a
	return new_string


def alternateCase(s):
	res = ''
	for i in range(len(s)):
		if s[i] >= 'a' and s[i] <= 'z':
			res = res + s[i].upper()
		elif s[i] >= 'A' and s[i] <= 'Z':
			res = res + s[i].lower()
		else:
			res = res + s[i]
	return res


def alternateCase(s):
	return ''.join((c.lower() if str.isupper(c) else c.upper() for c in s))


def alternateCase(s):
	result = ''
	if len(s) == 0 or s == ' ':
		return s
	for letter in s:
		if 'a' <= letter <= 'z':
			result += letter.upper()
		elif 'A' <= letter <= 'Z':
			result += letter.lower()
		else:
			result += letter
	return result


def alternateCase(s):
	lst = []
	for i in s:
		if i == i.upper():
			lst.append(i.lower())
		else:
			lst.append(i.upper())
	return ''.join(lst)


def alternateCase(s):
	new_s = ''
	for char in s:
		if ord(char) > 122 or ord(char) < 65:
			new_s += char
			continue
		if ord(char) >= 97:
			new_s += chr(ord(char) - 32)
		else:
			new_s += chr(ord(char) + 32)
	return new_s


def alternateCase(s):
	final = []
	for l in s:
		if l == l.lower():
			final.append(l.upper())
		elif l == l.upper():
			final.append(l.lower())
		else:
			final.append(' ')
	return ''.join(final)


def alternateCase(s):
	cout = []
	for letter in s:
		if letter == letter.upper():
			cout.append(letter.lower())
		elif letter == letter.lower():
			cout.append(letter.upper())
	return ''.join(cout)


import string

def alternateCase(s):
	UPPER = string.ascii_uppercase
	LOWER = string.ascii_lowercase
	result = []
	for letter in s:
		if letter in UPPER:
			result.append(letter.lower())
		else:
			result.append(letter.upper())
	return ''.join(result)


def alternateCase(s):
	new = ''
	for let in s:
		if let.isupper():
			new += let.lower()
		elif let.islower():
			new += let.upper()
		else:
			new += let
	return new


from string import ascii_uppercase as u, ascii_lowercase as l

def alternateCase(s):
	return s.translate(str.maketrans(u + l, l + u))


a = ord('a')
A = ord('A')
z = ord('z')
Z = ord('Z')
upperToLower = A - a
lowerToUpper = a - A

def alternateCase(s):
	str = ''
	for i in range(len(s)):
		if ord(s[i]) >= A and ord(s[i]) <= Z:
			str += chr(ord(s[i]) - upperToLower)
		elif ord(s[i]) >= a and ord(s[i]) <= z:
			str += chr(ord(s[i]) - lowerToUpper)
		else:
			str += s[i]
	return str


def alternateCase(s):
	new_text = ''
	for i in s:
		if i.islower():
			new_text += i.upper()
		else:
			new_text += i.lower()
	return new_text


def alternateCase(s):
	s = [letter for letter in s]
	for i in range(len(s)):
		if s[i] == s[i].upper():
			s[i] = s[i].lower()
		else:
			s[i] = s[i].upper()
	return ''.join(s)


def alternateCase(s):
	alternated = []
	for i in list(s):
		if i.isspace():
			alternated.append(i)
		if i.islower():
			alternated.append(i.upper())
		if i.isupper():
			alternated.append(i.lower())
	return ''.join(alternated)


def alternateCase(s):
	new_s = []
	for char in s:
		if char.isupper():
			new_s.append(char.lower())
		else:
			new_s.append(char.upper())
	return ''.join(new_s)


def alternateCase(s):
	s_list = s.split()
	new_s = []
	for char in s:
		if char.isupper():
			new_s.append(char.lower())
		else:
			new_s.append(char.upper())
	new_s_string = ''.join(new_s)
	return new_s_string


def alternateCase(s):
	final_ans = ''
	tokens = [c for c in s]
	for c in tokens:
		if c.isupper():
			final_ans = final_ans + c.lower()
		else:
			final_ans = final_ans + c.upper()
	return final_ans


def alternateCase(s):
	upper_letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	lower_letters = list(upper_letters.lower())
	upper_letters = list(upper_letters)
	ans = ''
	index = 0
	while index < len(s):
		char = s[index]
		if char == '' or char == ' ':
			ans += char
			index += 1
			continue
		if char in upper_letters:
			ans += char.lower()
		if char in lower_letters:
			ans += char.upper()
		index += 1
	return ans


def alternateCase(s):
	return ''.join([l.upper() if l.islower() else l.lower() if l.isupper() else l for l in s])


def alternateCase(s):
	text = ''
	for i in range(len(s)):
		if s[i].isupper() == True:
			text = text + s[i].lower()
		else:
			text = text + s[i].upper()
	return text


def alternateCase(s):
	a = s
	b = ''
	for i in range(len(a)):
		if str.isupper(a[i]):
			b += a[i].lower()
		elif a[i] == ' ':
			b += ' '
		else:
			b += a[i].upper()
	return b


def alternateCase(s):
	if len(s) == 0:
		return s
	res = []
	for x in s:
		if x.isupper():
			res.append(x.lower())
		elif x.islower():
			res.append(x.upper())
		else:
			res.append(x)
	return ''.join(res)


def alternateCase(s):
	ans = ''
	for c in s:
		if c.upper() == c:
			ans += c.lower()
		elif c.lower() == c:
			ans += c.upper()
	return ans


def alternateCase(s):
	lst = list()
	for i in s:
		if i.isupper():
			lst.append(i.lower())
		elif i.islower():
			lst.append(i.upper())
		else:
			lst.append(' ')
	return ''.join(lst)