0
[SOLVED]How to substitute int with their ascii value in a string?
Suppose a list: ["hello116her101", "wh97116isu112"] I want to substitute int with their ascii value between a-z (97-123). Then output list will be: ["hellothere", "whatisup"] The main problem i am facing is with integers in groups like "97116" which should become "at" (97=a & 116=t).
9 Respostas
+ 2
Carlos I wrote this last night, but then I got tired and went to sleep when you replied. I have tried it and it looks okay so far, but I haven't tested it thoroughly, so if there's a problem, please reply mentioning the words to test, so I can try to fix it.
https://code.sololearn.com/c1BFTHYcAy1O/?ref=app
+ 1
The challenge here I guess , is to correctly predict how many digits is to be read to be converted to a character.
+ 1
Ipang yeah i believe the guess should be between 2 to 3 chars.
Then can it be:
If len(integers chars checked)==2
Then substitute
If len(integers chars checked)==3
Then substitute
???
As if an integer less than 97 pops up then the substitution should skip??
+ 1
Ipang I am actually really confused about my codeđ”
https://code.sololearn.com/c2l7xCukzfzP/?ref=app
And this undebugable error makes me worse.
+ 1
Ipang Nicee!! That's what I wanted . It is the best i could have thought of.
I have tried many possible conditions in your code and it passes all. Thanks very much!!đ
+ 1
Ipang I have also tried to solve for hours last night and came up with this:
https://code.sololearn.com/c9rIgUSY1nle/?ref=app
I know it's not as much efficient as your. But kinda okayish.
Edit: And it also fails many conditions like "999hello116her101" which outputs "chelloher". instead of "c9hellothere".
+ 1
Carlos,
You're welcome
It's also a nice topic for practice đ
0
Carlos,
How far have you gone trying?
Can you share your code in the Description above for a review? â
0
Hint : typecast it