You're re-designing a blog and the blog's posts have the following format for showing the date and time a post was made: 

*Weekday* *Month* *Day*, *time*
e.g., 
Friday May 2, 7pm

You're running out of screen real estate, and on some pages you want to display a shorter format, *Weekday* *Month* *Day* that omits the time.

Write a function, shortenToDate, that takes the Website date/time in its original string format, and returns the shortened format.

Assume shortenToDate's input will always be a string, e.g. "Friday May 2, 7pm". Assume shortenToDate's output will be the shortened string, e.g., "Friday May 2".

Difficulty: EASY
Starter code: def shorten_to_date(long_date):
	

Solutions:
def shorten_to_date(long_date):
	return long_date.split(',')[0]


def shorten_to_date(long_date):
	return long_date[:long_date.index(',')]


def shorten_to_date(long_date):
	return long_date[:long_date.rfind(',')]


def shorten_to_date(long_date):
	index = long_date.index(',')
	new_string = long_date[:index]
	return new_string


import re

def shorten_to_date(long_date):
	return re.sub(',.+$', '', long_date)


def shorten_to_date(long_date):
	num = long_date.find(',')
	return long_date[0:num]


shorten_to_date = lambda d: d[:d.find(',')]


def shorten_to_date(long_date):
	(date, time) = long_date.split(',')
	return date


def shorten_to_date(long_date):
	a = len(long_date) - long_date.index(',')
	return long_date[:-a]


def shorten_to_date(long_date):
	for i in range(len(long_date)):
		if long_date[i] == ',':
			return long_date[:i]
	return long_date


shorten_to_date = lambda d: d.split(',')[0]


import re

def shorten_to_date(long_date):
	return re.sub(',\\s[0-9]+pm|,\\s[0-9]+am', '', long_date)


import re

def shorten_to_date(long_date):
	return re.sub(', ([1-9]|1[0-2])[ap]m', '', long_date)


def shorten_to_date(long_date):
	return long_date[:-5].replace(',', '')


def shorten_to_date(lon):
	return lon[:lon.find(',')]


def shorten_to_date(long_date):
	return ' '.join(long_date.split()[:-1]).replace(',', '')


def shorten_to_date(long_date):
	x = long_date.split(',')
	del x[-1]
	return x[0]


import re

def shorten_to_date(long_date):
	long_date = re.sub(', \\d\\d[pa]m', '', long_date)
	long_date = re.sub(', \\d[ap]m', '', long_date)
	return long_date


shorten_to_date = lambda long_date: long_date.split(',')[0]


from re import match

def shorten_to_date(long_date: str) -> str:
	return match('(?P<short_date>.+),', long_date).groupdict().get('short_date')


def shorten_to_date(long_date):
	f = long_date.find(', ')
	return long_date[:f]


def shorten_to_date(long_date):
	splitString = long_date.split()
	return splitString[0] + ' ' + splitString[1] + ' ' + splitString[2].rstrip(',')


def shorten_to_date(long_date):
	broken = long_date.split(' ')
	date = str(broken[2]).strip(',')
	return broken[0] + ' ' + broken[1] + ' ' + date


import re

def shorten_to_date(long_date):
	return re.match('[^,]+', long_date).group()


def shorten_to_date(long_date):
	end = long_date.index(',')
	return long_date[:end]


def shorten_to_date(long_date):
	index = long_date.find(',')
	return long_date[0:index]


def shorten_to_date(long_date):
	if long_date.endswith('pm') or long_date.endswith('am'):
		split_long_date = long_date.split(',', 1)
		return split_long_date[0]


def shorten_to_date(long_date):
	a = long_date.split(', ')
	b = ''.join(a[:-1])
	return b


def shorten_to_date(long_date):
	char = long_date.split()[:-1]
	tuple_char = (char[0], char[1], char[2][:-1])
	result = ' '.join(tuple_char)
	return result


def shorten_to_date(long_date):
	(short_date, spare) = long_date.split(',')
	return short_date


import re

def shorten_to_date(long_date):
	match_date = re.search('\\w*\\s\\w*\\s\\d*', long_date)
	return match_date.group(0)


def shorten_to_date(long_date):
	return ' '.join([i.replace(',', '') for i in long_date.split()[:-1]])


def shorten_to_date(long_date):
	for i in range(-6, -3):
		if long_date[i] == ',':
			return long_date[:i]


def shorten_to_date(long_date):
	a = long_date.split(',')
	x = list(a)
	return ' '.join(x[:-2] + x[:-1])


def shorten_to_date(long_date):
	cut_off = long_date.index(',')
	return long_date[:cut_off]


def shorten_to_date(long_date):
	list = long_date.split(',')
	return str(list[0])


def shorten_to_date(long_date):
	space = long_date.index(',')
	return long_date[:space]


def shorten_to_date(long_date):
	comma = long_date.find(',')
	return long_date[0:comma]


def shorten_to_date(long_date):
	date = long_date.split()
	actual = str(date[0] + ' ' + date[1] + ' ' + date[2])
	actual = actual.replace(',', '')
	return actual


def shorten_to_date(long_date):
	res = ''
	i = 0
	while long_date[i] != ',':
		res += long_date[i]
		i += 1
	return res


def shorten_to_date(long_date):
	komma = ','
	string_short = long_date.split(komma, 1)[0]
	return string_short


def shorten_to_date(long_date):
	long_date = long_date.replace(',', '')
	long_date = long_date.split(' ')
	del long_date[3]
	long_date = ' '.join(long_date)
	return long_date
print(shorten_to_date('Monday February 2, 8pm'))


def shorten_to_date(long_date):
	return ' '.join(list(long_date.split())[0:3]).replace(',', '')


def shorten_to_date(date):
	date = date.replace(',', '').split(' ')
	return date[0] + ' ' + date[1] + ' ' + date[2]


def shorten_to_date(d):
	s = ''
	for i in d:
		if i == ',':
			break
		else:
			s += i
	return s


def shorten_to_date(long_date):
	string = str(long_date)
	string = string.replace(',', '')
	string = string.split(' ')
	string.pop()
	string = ' '.join(string)
	return string


def shorten_to_date(long_date):
	ld = long_date
	ind = ld.index(',')
	return ld[:ind]


def shorten_to_date(long_date):
	string = ''
	for c in long_date:
		if c != ',':
			string += c
		else:
			return string


def shorten_to_date(long_date: str) -> str:
	return long_date.split(',', maxsplit=1)[0]


def shorten_to_date(long_date):
	sep = long_date.find(',')
	return long_date[:sep]


def shorten_to_date(long_date):
	a = long_date.find(',')
	b = long_date[0:a]
	return b


def shorten_to_date(long_date):
	short_date = ''
	for i in range(len(long_date)):
		if long_date[i] != ',':
			short_date = short_date + long_date[i]
		else:
			break
	print(short_date)
	return short_date


def shorten_to_date(long_date):
	if long_date[-4] in '123456789':
		return long_date[0:-6]
	else:
		return long_date[0:-5]


def shorten_to_date(long_date):
	(jour, mois, year) = (long_date.split()[0], long_date.split()[1], long_date.split()[2])
	if year[1] == ',':
		year = year[0]
	elif year[2] == ',':
		year = year[0] + year[1]
	date = jour + ' ' + mois + ' ' + year
	return date


def shorten_to_date(long_date):
	return ' '.join(long_date.split(' ')[:3]).replace(',', '')


def shorten_to_date(long_date):
	split1 = long_date.split(', ')
	split2 = split1[0]
	return split2


def shorten_to_date(long_date):
	for element in long_date:
		a = long_date.index(',')
	return long_date[0:a]


def shorten_to_date(long_date):
	short = []
	words = long_date.split(' ')
	for word in words:
		if word != words[2] and word != words[3]:
			short.append(word)
		elif word == words[2]:
			short.append(word[:-1])
	shortjoin = ' '.join(short)
	return shortjoin


def shorten_to_date(long_date: str) -> str:
	return long_date[:long_date.find(',')]


def shorten_to_date(long_date):
	short_date = long_date.replace(',', '').split(' ')
	short_date.pop()
	return ' '.join(short_date)


def shorten_to_date(long_date):
	return long_date[:-4].replace(',', '').rstrip()


def shorten_to_date(long_date):
	b = long_date.split(',')
	return str(b[0])


def shorten_to_date(long_date):
	newdate = long_date.replace(',', '')
	lst = list(newdate.split(' '))
	listnew = lst[:4]
	return f'{listnew[0]} {listnew[1]} {listnew[2]}'


def shorten_to_date(long_date):
	shorten = ''
	for i in long_date:
		if i == ',':
			break
		shorten += i
	return shorten


def shorten_to_date(long_date):
	counter = 0
	for i in long_date:
		if i == ',':
			counter = long_date.find(i)
	return long_date[:counter]


def shorten_to_date(long_date):
	date_split = long_date.split()
	date_split_no_time = date_split[:3]
	short_date = ' '.join(date_split_no_time)
	short_date = short_date.replace(',', '')
	return short_date


def shorten_to_date(long_date):
	long_date = long_date.rsplit(' ', 1)[0].replace(',', '')
	return long_date


def shorten_to_date(long_date):
	date_list = long_date.split(' ')
	del date_list[-1]
	short_date = ' '.join(date_list)
	short_date = short_date[:-1]
	return short_date


def shorten_to_date(long_date):
	short = ''
	for i in long_date:
		if i == ',':
			break
		short += i
	return short


def shorten_to_date(long_date):
	x = ''
	for i in long_date:
		if i != ',':
			x += i
		else:
			break
	return x


def shorten_to_date(ld):
	return ld[:ld.find(',')]


def shorten_to_date(long_date):
	pos = 0
	for i in range(len(long_date)):
		pos += 1
		if long_date[i] == ',':
			break
	pos -= 1
	return long_date[:pos]


def shorten_to_date(long_date):
	return long_date.replace(long_date[long_date.index(','):], '')


def shorten_to_date(long_date):
	x = []
	for i in range(len(long_date)):
		if long_date[i] == ',':
			break
		x.append(long_date[i])
	s = ''.join(x)
	return s


import re

def shorten_to_date(long_date):
	return re.sub(',\\s\\d\\w.+', '', long_date)


def shorten_to_date(long_date):
	long_date.split(', ')
	if '10pm' in long_date or '11pm' in long_date or '12pm' in long_date or ('10am' in long_date) or ('11am' in long_date) or ('12am' in long_date):
		return long_date[0:len(long_date) - 6]
	else:
		return long_date[0:len(long_date) - 5]


def shorten_to_date(long_date):
	new_date = long_date.partition(',')
	return new_date[0]


def shorten_to_date(long_date):
	g = long_date.rfind(',')
	return long_date[0:g]


def shorten_to_date(long_date):
	x = long_date.split(',')
	shortened = x[:1]
	emptystring = ''
	for eachchar in shortened:
		emptystring = emptystring + eachchar
	return emptystring


def shorten_to_date(long_date):
	sep = ','
	short_date = long_date.split(sep)[0]
	return short_date


def shorten_to_date(long_date):
	ans = ''
	i = 0
	while long_date[i] != ',':
		ans = ans + long_date[i]
		i = i + 1
	return ans


def shorten_to_date(x):
	xs = x.rsplit(', ', 1)
	print(xs)
	xs.pop(1)
	print(xs)
	short_date = ' '
	return short_date.join(xs)


def shorten_to_date(long_date):
	return ' '.join(long_date.split(',')[0:-1])


def shorten_to_date(long_date):
	sep = ','
	return sep.join(long_date.split(sep)[:-1])


def shorten_to_date(long_date):
	l = [x.strip(',') for x in long_date.split(',')]
	del l[-1]
	return ' '.join(l)


def shorten_to_date(long_date):
	bruh = long_date[:long_date.index(',')]
	return bruh


import re

def shorten_to_date(long_date):
	return re.sub(', [0-9]{1,2}(a|p)m', '', long_date)