+ 2

Conversion Program of strings to numbers

I need help with writing a program that convert a string of letters to numbers. I,m thinking of a criteria where a letter is given a numerical number according to its position in the alphabet i.e A = 1, B = 2, 
. etc But where, special characters remain unchanged Example: Input: Bed-1#2%3 Output: 254-1#2%3

29th Nov 2022, 3:56 PM
Izaiah Kay
Izaiah Kay - avatar
10 Answers
1st Aug 2023, 6:36 PM
Izaiah Kay
Izaiah Kay - avatar
+ 7
Izaiah Kay , please link your code here so that we can see where the issue is.
29th Nov 2022, 4:37 PM
Lothar
Lothar - avatar
+ 4
Hint: Depending of what you like more you could - define a list or better a dictionary with all characters and its corresponding numbers / special characters; - receive input string; - define results string; - and take from your list / dictionary the right item and add to the result; - print the result. For more try to code it and show your attempt here.
29th Nov 2022, 4:39 PM
JaScript
JaScript - avatar
+ 3
Lothar JaScript I’m still working on it
29th Nov 2022, 4:45 PM
Izaiah Kay
Izaiah Kay - avatar
3rd Dec 2022, 5:31 AM
Izaiah Kay
Izaiah Kay - avatar
+ 3
Izaiah Kay , You never defined the input_list what you try to use in below statement. I think you wanted have here the input string, you declared before. output_list = [ str(get_index(x)) for x in list(input)]
3rd Dec 2022, 2:03 PM
JaScript
JaScript - avatar
+ 2
Thanks JaScript . Got it
3rd Dec 2022, 2:06 PM
Izaiah Kay
Izaiah Kay - avatar
+ 2
Happy coding Izaiah Kay !
3rd Dec 2022, 2:12 PM
JaScript
JaScript - avatar
+ 2
JaScript I am just messing around with the code, its not a real encryption.Its just a foundation for an encryption i intend to code in future. I just named it that 😄
4th Dec 2022, 7:11 AM
Izaiah Kay
Izaiah Kay - avatar
+ 1
Whether and when this encription really works that can be seen, when do you can have a result from a decriptor, which is the same as the input string. Did you check it Izaiah Kay ?
3rd Dec 2022, 3:21 PM
JaScript
JaScript - avatar