How can I change a number in a string into a string? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How can I change a number in a string into a string?

Guys I was solving my code coach challenges and I saw a challenge 'No Numeral' and I started solving but I found out that I need to change the "2" and "3" in the string to "two"and "three". Problem I need 2 pumpkins and 3 apples. Change to I need two pumpkins and three apples. HOW CAN I DO THAT IN C++ python c# and java

11th May 2020, 11:07 AM
Isaac Duah [Active!]
Isaac Duah [Active!] - avatar
9 Answers
+ 2
U have to replace 2 with two. U can do that in c++ using switch case and for python u can use dictionary. There are others ways too to do that.
11th May 2020, 11:35 AM
Peter Parker
Peter Parker - avatar
+ 2
Peter Parker give me the code
11th May 2020, 11:35 AM
Isaac Duah [Active!]
Isaac Duah [Active!] - avatar
+ 2
Peter Parker It worked thank you but if you find the answer for c++ post here.
11th May 2020, 11:39 AM
Isaac Duah [Active!]
Isaac Duah [Active!] - avatar
11th May 2020, 11:45 AM
Peter Parker
Peter Parker - avatar
+ 1
https://code.sololearn.com/cN1wO8h6vG59/?ref=app
11th May 2020, 11:37 AM
Peter Parker
Peter Parker - avatar
+ 1
U got the logic, right? You can write your own code in c++.
11th May 2020, 11:41 AM
Peter Parker
Peter Parker - avatar
+ 1
Peter Parker Yes I am just working on it but can you create a dictionary in C++ for me what I know is Array in C++. And can array work in the same way?
11th May 2020, 11:43 AM
Isaac Duah [Active!]
Isaac Duah [Active!] - avatar
+ 1
Peter Parker thanks you are the best
11th May 2020, 11:50 AM
Isaac Duah [Active!]
Isaac Duah [Active!] - avatar