title: Given a string containing uppercase alphabets (A-Z), compress the string using Run Length encoding
body: <p>Given a string containing uppercase alphabets (A-Z), compress the string using Run Length encoding. Repetition of character has to be replaced by storing the length of that run.</p>
  
  <p>I tried the following codes</p>
  
  <pre><code>#Code 1: Tried on my own
  
  
      def encode(message):
          list1=[]
          for i in range (0,len(message)):
              count = 1
              while(i &lt; len(message)-1 and message[i]==message[i+1]):
                  count+=1
                  i+=1
                  list1=str(count)+message[i]
                  return list1
      encoded_message=encode("ABBBBCCCCCCCCAB")
      print(encoded_message)
  
  
  
  Input:AAAABBBBCCCCCCCC  
  Expected Output: 4A4B8C
  
  
  
  #code 2:I tried this by looking at another code based on run-length encoding
  
      def encode(message):
          list1=[]
          count=1
          for i in range (1,len(message)):
              if(message[i]==message[i-1]):
                  count+=1
              else:
                  list1.append((count,list1[i-1]))
                  count=1
              if i == len(messege) - 1 :
                  list1.append((count , data[i]))
          return list1
  
      encoded_message=encode("ABBBBCCCCCCCCAB")
      print(encoded_message)
  </code></pre>
  
  <p>Input:AAAABBBBCCCCCCCC<br>
  Expected Output: 4A4B8C</p>
  
  <p>The first code gives output as 2B</p>