+ 1

How to turn user input into numbers

How do you take some use input, for example sun and turn it into numbers like 19, 21, 14 which are their place in the alphabet.

1st Jul 2018, 5:55 PM
Trp100
Trp100 - avatar
3 ответов
+ 2
easy, but relatively long way: make cases like switch input case "a" { output 1} or the harder way: take the charcode of the input (a = 65, b = 66 and so on) and then do charcode - 64 to get the place of the alphabet
1st Jul 2018, 6:20 PM
Roel
Roel - avatar
1st Jul 2018, 10:02 PM
Markus Kaleton
Markus Kaleton - avatar
+ 1
thanks for the answers
1st Jul 2018, 11:27 PM
Trp100
Trp100 - avatar