In this Kata, you will be given a string that may have mixed uppercase and lowercase letters and your task is to convert that string to either lowercase only or uppercase only based on: 

* make as few changes as possible. 
* if the string contains equal number of uppercase and lowercase letters, convert the string to lowercase. 

For example:
```Haskell
solve("coDe") = "code". Lowercase characters > uppercase. Change only the "D" to lowercase.
solve("CODe") = "CODE". Uppercase characters > lowecase. Change only the "e" to uppercase.
solve("coDE") = "code". Upper == lowercase. Change all to lowercase.
```

More examples in test cases. Good luck!

Please also try:
 
[Simple time difference](https://www.codewars.com/kata/5b76a34ff71e5de9db0000f2)

[Simple remove duplicates](https://www.codewars.com/kata/5ba38ba180824a86850000f7)

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def solve(s):
	

Solutions:
def solve(s):
	return s.upper() if sum(map(str.isupper, s)) * 2 > len(s) else s.lower()


def solve(s):
	upper = 0
	lower = 0
	for char in s:
		if char.islower():
			lower += 1
		else:
			upper += 1
	if upper == lower or lower > upper:
		return s.lower()
	else:
		return s.upper()


def solve(s):
	lower_case = [l for l in s if l.islower()]
	upper_case = [l for l in s if l.isupper()]
	if len(upper_case) > len(lower_case):
		return s.upper()
	return s.lower()


def solve(s):
	n = len(s) // 2
	upper_count = 0
	for c in s:
		if c.isupper():
			upper_count += 1
		if upper_count > n:
			return s.upper()
	return s.lower()


def solve(s):
	return s.upper() if sum((i.isupper() for i in s)) > len(s) / 2 else s.lower()


def solve(s):
	return s.lower() if sum((1 for i in s if i in 'abcdefghijklmnopqrstuvwxyz')) >= len(s) / 2 else s.upper()


def solve(s):
	count_upper = 0
	count_lower = 0
	for i in range(len(s)):
		if s[i].isupper() == True:
			count_upper += 1
		else:
			count_lower += 1
		if count_upper > len(s) / 2 + 1 or count_lower >= len(s) / 2 + 1:
			break
	result = ''
	if count_lower < count_upper:
		result = s.upper()
	else:
		result = s.lower()
	return result


def solve(s):
	counter = 0
	for char in s:
		if char.isupper():
			counter += 1
	print(counter)
	return s.lower() if counter <= len(s) / 2 else s.upper()


def solve(s):
	l = 0
	u = 0
	for x in s:
		if x.islower():
			l += 1
		else:
			u += 1
	if l >= u:
		return s.lower()
	else:
		return s.upper()


def solve(s):
	(u, l) = (0, 0)
	for i in s:
		if i.isupper():
			u += 1
		else:
			l += 1
	return s.lower() if l >= u else s.upper()


def solve(s):
	return s.upper() if sum((1 for c in s if c.isupper())) > len(s) / 2 else s.lower()


def solve(s):
	return s.upper() if sum((1 for c in s if c.isupper())) > sum((1 for c in s if c.islower())) else s.lower()


def solve(s):
	up = []
	low = []
	for i in s:
		if i.isupper():
			up.append(i)
		else:
			low.append(i)
	if len(low) > len(up):
		return s.lower()
	elif len(low) < len(up):
		return s.upper()
	else:
		return s.lower()


def solve(s):
	count_u = 0
	count_l = 0
	for letter in s:
		if letter.isupper():
			count_u += 1
		elif letter.islower():
			count_l += 1
	if count_u > count_l:
		return s.upper()
	else:
		return s.lower()


def solve(a):
	b = 0
	m = 0
	for i in range(len(a)):
		if a[i] == a[i].lower():
			m += 1
		else:
			b += 1
	if m >= b:
		return a.lower()
	else:
		return a.upper()


def solve(s):
	uppercount = 0
	for i in s:
		if i.isupper():
			uppercount += 1
		if uppercount > len(s) / 2:
			s = s.upper()
		else:
			s = s.lower()
	return s


def solve(s):
	l = len([c for c in s if c.islower()])
	u = len(s) - l
	return s.upper() if u > l else s.lower()


def solve(s):
	n = len(s) // 2
	up = 0
	for i in s:
		if i.isupper():
			up += 1
	if up > n:
		return s.upper()
	return s.lower()


def solve(s):
	return (s.lower(), s.upper())[len(s) > sum(map(str.islower, s)) * 2]


from string import ascii_lowercase

def solve(s):
	lowercase_counter = 0
	uppercase_counter = 0
	half_length = len(s) / 2
	for letter in s:
		if letter in ascii_lowercase:
			lowercase_counter += 1
			if lowercase_counter > half_length:
				return s.lower()
		else:
			uppercase_counter += 1
			if uppercase_counter > half_length:
				return s.upper()
	return s.lower()


def solve(s):
	return s.lower() if sum(map(str.islower, s)) >= sum(map(str.isupper, s)) else s.upper()


def solve(s):
	return (s.lower(), s.upper())[sum((1 if x.isupper() else -1 for x in s)) > 0]


def solve(s):
	return s.upper() if len(s) / 2 > len([i for i in range(len(s)) if s[i].islower()]) else s.lower()


def solve(s):
	return s.upper() if sum((c.islower() for c in s)) < len(s) / 2 else s.lower()


def solve(s):
	bcount = 0
	i = 0
	acount = 0
	while i < len(s):
		if s[i].isupper():
			acount += 1
			i += 1
		elif s[i].islower():
			bcount += 1
			i += 1
	if bcount >= acount:
		print(bcount)
		return s.lower()
	if acount > bcount:
		return s.upper()
	else:
		return s.lower()


def solve(s):
	upper = 0
	lower = 0
	for i in s:
		if i.isupper() == True:
			upper += 1
		else:
			lower += 1
	if upper > lower:
		s = s.upper()
	else:
		s = s.lower()
	return s


solve = lambda s: s.lower() if sum((c.isupper() for c in s)) <= len(s) / 2 else s.upper()


def solve(s):
	l = 0
	h = 0
	for i in s:
		if ord(i) < 91:
			h += 1
		else:
			l += 1
	return s.upper() if h > l else s.lower()


solve = lambda s: s.upper() if len([l for l in s if ord(l) > 64 and ord(l) < 91]) > len(s) // 2 else s.lower()


solve = lambda s: getattr(s, ['lower', 'upper'][sum(map(str.isupper, s)) > len(s) // 2])()


def solve(s):
	upr = 0
	lwr = 0
	for i in s:
		if i.isupper():
			upr += 1
		else:
			lwr += 1
	if upr > lwr:
		return s.upper()
	else:
		return s.lower()


def solve(s):
	return s.lower() if len(list(filter(lambda x: x.islower(), s))) * 2 >= len(s) else s.upper()


def solve(s):
	(lcase, ucase) = (0, 0)
	for i in s:
		if i.isupper():
			ucase = ucase + 1
		else:
			lcase = lcase + 1
	return s.lower() if lcase >= ucase else s.upper()


def solve(s):
	up = 0
	down = 0
	for str in s:
		if str.isupper() == True:
			up = up + 1
		else:
			down = down + 1
	if up > down:
		string = s.upper()
	else:
		string = s.lower()
	return string


def solve(s):
	lower_count = 0
	for i in s:
		if i.islower():
			lower_count += 1
	if 2 * lower_count >= len(s):
		return s.lower()
	return s.upper()


import string

def solve(s):
	return s.lower() if [l in string.ascii_lowercase for l in s].count(True) >= len(s) // 2 else s.upper()


def solve(s):
	return s.upper() if sum([1 for x in s if x in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ']) > len(s) / 2 else s.lower()


def solve(s):
	lower_case = [i for i in s if i.islower()]
	upper_case = [i for i in s if i.isupper()]
	return s.lower() if len(lower_case) >= len(upper_case) else s.upper()


import string

def solve(s):
	(low, up) = (string.ascii_lowercase, string.ascii_uppercase)
	(l_c, u_c) = (0, 0)
	for c in s:
		if c in low:
			l_c += 1
		else:
			u_c += 1
	if l_c >= u_c:
		return s.lower()
	elif l_c < u_c:
		return s.upper()


def solve(s):
	if s.islower() or s.isupper():
		return s
	elif len([i for i in s if i.isupper()]) > len([i for i in s if i.islower()]):
		return s.upper()
	else:
		return s.lower()


def solve(s):
	lowercount = 0
	uppercount = 0
	for x in s:
		for y in x:
			if y.islower():
				lowercount = lowercount + 1
			if y.isupper():
				uppercount = uppercount + 1
			print(y)
	if lowercount >= uppercount:
		s = s.lower()
	if lowercount < uppercount:
		s = s.upper()
	return s


def solve(s):
	i = j = 0
	i = len([i + 1 for a in [*s] if a.isupper()])
	j = len([j + 1 for a in [*s] if a.islower()])
	return s.lower() if i < j or i == j else s.upper()


def solve(s):
	upper = 0
	lower = 0
	for letter in s:
		if letter.isupper():
			upper += 1
		else:
			lower += 1
	if upper == lower:
		return s.lower()
	elif upper > lower:
		return s.upper()
	else:
		return s.lower()


def solve(s):
	upperS = 0
	lowerS = 0
	for letter in s:
		if letter.islower():
			lowerS += 1
		else:
			upperS += 1
	if upperS > lowerS:
		return s.upper()
	else:
		return s.lower()


def solve(s):
	up = 0
	for c in s:
		if c.isupper():
			up += 1
	if up > len(s) / 2:
		return s.upper()
	else:
		return s.lower()


def count_characters(s):
	uppercase = 0
	lowercase = 0
	for i in range(len(s)):
		if s[i].islower():
			lowercase += 1
		else:
			uppercase += 1
	if uppercase > lowercase:
		return 1
	else:
		return 0

def solve(s):
	if count_characters(s) == 1:
		return s.upper()
	else:
		return s.lower()


def solve(s):
	s_list = list(s)
	count_lower = 0
	count_upper = 0
	for i in s_list:
		if i.islower() == True:
			count_lower += 1
		else:
			count_upper += 1
	if count_lower < count_upper:
		return s.upper()
	else:
		return s.lower()


def solve(s):
	countlow = 0
	countupp = 0
	for letter in s:
		if letter.isupper():
			countupp += 1
		elif letter.islower():
			countlow += 1
	return s.lower() if countlow - countupp >= 0 else s.upper()


def solve(s):
	low_cnt = 0
	up_cnt = 0
	temp = list(s)
	for item in temp:
		if item.islower():
			low_cnt += 1
		else:
			up_cnt += 1
	if low_cnt >= up_cnt:
		return s.lower()
	else:
		return s.upper()


def solve(s):
	(upper, lower) = ([], [])
	for w in s:
		if w.isupper():
			upper.append(w)
		else:
			lower.append(w)
	if len(upper) == len(lower) or len(upper) < len(lower):
		return s.lower()
	else:
		return s.upper()


def solve(s):
	l = sum(map(lambda x: x.islower(), s))
	u = len(s) - l
	if l >= u:
		return s.lower()
	else:
		return s.upper()


def solve(s):
	(up, lw) = (0, 0)
	for i in s:
		if i.isupper():
			up += 1
		else:
			lw += 1
	if lw >= up:
		return s.lower()
	else:
		return s.upper()


def solve(s):
	UpperChars = 0
	LowerChars = 0
	for i in s:
		Checked_i = i.isupper()
		if Checked_i is True:
			UpperChars += 1
		else:
			LowerChars += 1
	if UpperChars > LowerChars:
		s = s.upper()
	elif LowerChars > UpperChars or LowerChars == UpperChars:
		s = s.lower()
	return s


def solve(s):
	n = 0
	for i in s:
		n += int(i.isupper())
	if n > len(s) // 2:
		return s.upper()
	else:
		return s.lower()


def solve(s):
	num_upper = sum([1 for ch in s if ch.isupper()])
	num_lower = sum([1 for ch in s if ch.islower()])
	if num_upper > num_lower:
		return s.upper()
	return s.lower()


def solve(s):
	ups = 0
	lows = 0
	for i in s:
		if i == i.upper():
			ups += 1
		else:
			lows += 1
	if ups == lows or lows > ups:
		return s.lower()
	return s.upper()


def solve(s):
	l = 0
	u = 0
	for i in s:
		if i.islower():
			l += 1
		else:
			u += 1
	if l > u:
		return s.lower()
	elif u > l:
		return s.upper()
	elif u == l:
		return s.lower()


solve = lambda s: [s.upper, s.lower][sum((1 if ord(c) < 96 else -1 for c in s)) <= 0]()


def solve(s):
	list1 = [char for char in s]
	upperlist = [letter for letter in list1 if letter.isupper()]
	lowerlist = [letter for letter in list1 if letter.islower()]
	if len(lowerlist) >= len(upperlist):
		return s.lower()
	else:
		return s.upper()


def solve(s):
	lower_count = 0
	upper_count = 0
	for char in s:
		if char.islower():
			lower_count += 1
		if char.isupper():
			upper_count += 1
	if upper_count > lower_count:
		return s.upper()
	if lower_count >= upper_count:
		return s.lower()


def solve(s):
	list_1 = [char for char in s]
	x = 0
	for c in [char for char in s]:
		if c.isupper():
			x = x + 1
	if x > len(s) / 2:
		s = s.upper()
	else:
		s = s.lower()
	return s


def solve(s):
	low = 0
	up = 0
	for i in s:
		if i.islower():
			low += 1
		else:
			up += 1
	if up > low:
		return s.upper()
	return s.lower()


def solve(s):
	countU = 0
	countL = 0
	for x in s:
		if x.isupper():
			countU += 1
		else:
			countL += 1
	if countU > countL:
		return s.upper()
	else:
		return s.lower()


def solve(s):
	(cup, clw) = (0, 0)
	for c in s:
		if c.isupper():
			cup += 1
			if cup > len(s) / 2:
				return s.upper()
		else:
			clw += 1
			if clw > len(s) / 2:
				return s.lower()
	else:
		return s.lower()


def solve(s):
	c = 0
	for x in s:
		if x.isupper():
			c = c + 1
	if c > len(s) / 2:
		return s.upper()
	return s.lower()


def solve(s):
	case = 0
	for char in s:
		if char.isupper():
			case += 1
		else:
			case -= 1
	if case > 0:
		return s.upper()
	else:
		return s.lower()


def solve(s):
	a = sum([int(c.islower()) for c in s])
	b = sum([int(c.isupper()) for c in s])
	if a < b:
		return s.upper()
	else:
		return s.lower()


def solve(s):
	upper_count = 0
	lower_count = 0
	for c in s:
		if c.isupper():
			upper_count += 1
		else:
			lower_count += 1
	return s.lower() if lower_count >= upper_count else s.upper()


def solve(s):
	res = 0
	for i in [x for x in s]:
		if i.isupper():
			res += 1
		else:
			res -= 1
	return s.lower() if res <= 0 else s.upper()


def solve(s):
	big = 0
	small = 0
	for x in s:
		if 65 <= ord(x) <= 90:
			big += 1
		else:
			small += 1
	return s.lower() if small >= big else s.upper()


def solve(msg):
	l = 'abcdefghijklmnopqrstuvwxyz'
	U = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	msg = list(msg)
	(lc, Uc) = (0, 0)
	for i in range(len(msg)):
		if msg[i] in l:
			lc += 1
		if msg[i] in U:
			Uc += 1
	if lc > Uc or lc == Uc:
		return ''.join(msg).lower()
	else:
		return ''.join(msg).upper()


def solve(s):
	string = ''
	upper = 0
	lower = 0
	for letters in range(len(s)):
		if s[letters].isupper():
			upper += 1
		else:
			lower += 1
	if upper > lower:
		string += s.upper()
	else:
		string += s.lower()
	return string


def solve(s):
	x = list(s)
	upper = 0
	lower = 0
	for y in x:
		if y.isupper() == True:
			upper = upper + 1
		else:
			lower = lower + 1
	if upper > lower:
		return s.upper()
	else:
		return s.lower()


def solve(s):
	score = 0
	for l in list(s):
		score += 1 if l.isupper() else -1
	return s.upper() if score > 0 else s.lower()


def solve(s):
	sum_low = 0
	sum_upp = 0
	for el in s:
		if el == el.lower():
			sum_low += 1
		elif el == el.upper():
			sum_upp += 1
	if sum_low >= sum_upp:
		return s.lower()
	else:
		return s.upper()


def solve(s):
	count_lower = len([c for c in s if c.islower()])
	count_upper = len([c for c in s if c.isupper()])
	if count_lower < count_upper:
		return s.upper()
	elif count_lower >= count_upper:
		return s.lower()


import string

def solve(s):
	sum = 0
	for i in range(len(s)):
		if s[i] in string.ascii_lowercase:
			sum += 1
	return s.lower() if sum >= len(s) / 2 else s.upper()


def solve(s):
	s_upper = s.upper()
	s_lower = s.lower()
	if s == s_upper:
		return s
	elif s == s_lower:
		return s
	lower_change = 0
	upper_change = 0
	for i in range(0, len(s)):
		if s_upper[i] != s[i]:
			upper_change += 1
		if s_lower[i] != s[i]:
			lower_change += 1
	if upper_change < lower_change:
		return s_upper
	return s_lower


def solve(s):
	import string
	lower_alphabet = list(string.ascii_lowercase)
	upper_alphabet = list(string.ascii_uppercase)
	count_lower = 0
	count_upper = 0
	for i in s:
		if i in lower_alphabet:
			count_lower = count_lower + 1
		elif i in upper_alphabet:
			count_upper = count_upper + 1
	if count_lower >= count_upper:
		s = s.lower()
	else:
		s = s.upper()
	return s


def solve(s):
	l = 0
	z = 0
	for b in s:
		if b.islower():
			l += 1
		else:
			z += 1
	if l >= z:
		return s.lower()
	else:
		return s.upper()


def solve(s):
	lower_count = 0
	for i in range(len(s)):
		if s[i].islower():
			lower_count += 1
	upper_count = len(s) - lower_count
	if lower_count < upper_count:
		return s.upper()
	return s.lower()


def solve(s):
	up = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
	low = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
	letter_up = 0
	letter_low = 0
	for letter in s:
		if letter in up:
			letter_up += 1
		elif letter in low:
			letter_low += 1
	if letter_up > letter_low:
		return s.upper()
	else:
		return s.lower()


def solve(s):
	mayus = 0
	minus = 0
	for i in range(len(s)):
		if ord(s[i]) >= 97 and ord(s[i]) <= 122:
			minus += 1
		elif ord(s[i]) >= 65 and ord(s[i]) <= 90:
			mayus += 1
	if minus > mayus or mayus == minus:
		return s.lower()
	else:
		return s.upper()


def solve(s):
	a = [i for i in s if i.lower() != i]
	return s.upper() if len(a) > len(s) / 2 else s.lower()


import string

def solve(s):
	if len(s) / len(list((i for i in s if i in string.ascii_lowercase))) <= 2:
		return s.lower()
	else:
		return s.upper()