Find Number

Problem 4

Problem Statement

Hari needs to convert alphabets to their corresponding numerical positions (a = 1, b = 2, …, z = 26). Help him with the conversions!


Input Format:

The first line contains an integer, T, representing the number of test cases (1 <= T <= 10).

Each test case consists of a single line containing an alphabet (either uppercase or lowercase).

Output Format:

For each test case, print the corresponding number on a new line.

Constraints:

  • Alphabets can be in both uppercase and lowercase.
Sample Input
Sample Output

Solution

file_type_python find_number.py
for _ in range(int(input())):
    c = input()
    print(ord(c.upper()) - ord('A') + 1)

Comments

Load Comments