SimeonTs

SUPyF2 Text-Pr.-More-Ex. - 02. Ascii Sumator

Oct 27th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. """
  2. Text Processing - More Exercises
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1741#1
  4.  
  5. SUPyF2 Text-Pr.-More-Ex. - 02. Ascii Sumator
  6.  
  7. Problem:
  8. Write a program that prints a sum of all characters between two given characters (their ascii code).
  9. On the first line you will get a character. On the second line you get another character.
  10. On the last line you get a random string. Find all the characters between the two given and print their ascii sum.
  11.  
  12. Examples:
  13. Input:
  14. .
  15. @
  16. dsg12gr5653feee5
  17.  
  18. Output:
  19. 363
  20.  
  21. Input:
  22. ?
  23. E
  24. @ABCEF
  25.  
  26. Output:
  27. 262
  28. """
  29. a = ord(input())
  30. b = ord(input())
  31. text = [ord(x) for x in input()]
  32. start = min(a, b)
  33. end = max(a, b)
  34. total = 0
  35. for i in text:
  36.     if start < i < end:
  37.         total += i
  38. print(total)
Add Comment
Please, Sign In to add comment