From 60b2808de54f34a0cc39293e6cc442c6ffd9b98c Mon Sep 17 00:00:00 2001 From: Sai Sahith <91070868+sai-sahith7@users.noreply.github.com> Date: Tue, 31 May 2022 20:29:52 +0530 Subject: [PATCH] day 2 --- POD/Week2-Strings/day 2.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 POD/Week2-Strings/day 2.py diff --git a/POD/Week2-Strings/day 2.py b/POD/Week2-Strings/day 2.py new file mode 100644 index 0000000..ae5069e --- /dev/null +++ b/POD/Week2-Strings/day 2.py @@ -0,0 +1,7 @@ +t = int(input()) #number of test cases input +for i in range(t): + string = sorted(input()) #sorting in alphabetical order + s = 0 + for j in range(len(string)): + s += (j+1)*(ord(string[j]) - 96) #adding product of position of letter in string and position of letter in the alphabets + print(s) #printing the final power