DiYane

Sum of Chars

Jul 28th, 2023
748
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | Help | 0 0
  1. def calculate_ascii_sum(N):
  2.     total_sum = 0
  3.     for _ in range(N):
  4.         letter = input().strip()
  5.         total_sum += ord(letter)
  6.  
  7.     return total_sum
  8.  
  9. # Input
  10. N = int(input())
  11.  
  12. # Calculate the total sum
  13. total_sum = calculate_ascii_sum(N)
  14.  
  15. # Print the result
  16. print(f"The sum equals: {total_sum}")
  17.  
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment