I need to create a function called compress that compresses a string by replacing any repeated letters with a letter and number. My function should return the shortened vers
gstr="aaabbccccffffdee"
last=gstr[0]
count=0
rstr=""
for i in gstr:
if i==last:
count=count+1
elif i!=last:
rstr=rstr+last+str(count)
count=1
last=i
rstr=rstr+last+str(count)
print ("Required string for given string {} after conversion is {}.".format(gstr,rstr))