Skip to content

Instantly share code, notes, and snippets.

@linxlunx
Created October 17, 2016 15:10
Show Gist options
  • Save linxlunx/2c005e2688835afe33edef9cf144fe07 to your computer and use it in GitHub Desktop.
Save linxlunx/2c005e2688835afe33edef9cf144fe07 to your computer and use it in GitHub Desktop.
Count input characters
#!/usr/bin/env python
# only need a few minutes if I calm down
# aaarrrgggh
string = raw_input() + " "
texts = list(string)
final_texts = ""
x = 0
for num in xrange(len(texts)-1):
if texts[num] != texts[num+1]:
final_texts += texts[num]
x += 1
if x - 1 != 0:
final_texts += str(x)
x = 0
else:
x += 1
print final_texts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment