Python Forum
convert words to nums and vica versa - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: convert words to nums and vica versa (/thread-13629.html)



convert words to nums and vica versa - Nimtram - Oct-24-2018

Hi everyone,

just started learning python3 at university. We got a homework and I do not litterally know where to start.
We are asked to make a program that converts numbers from 0-999999 to words. for example: input: 587 output: fivehundredeightyseven.

And the same vica versa: input: onetohursandfivehundredseventytwo outut: 1572

I unferstand from my little experience that I will make something like: nums=["one", "two"..."thoursand"].
But I do not know how to create the algoritm for reading the input. to recognise that twohundred= "two" + "hundred". the input and output is supposed to be without spaces everytime.

I would appriciate so much if anyone helps me... Even better if someone gives me some contact and I will be able to write to the same person with some problems during programming...

Have a nice day everyone.


RE: convert words to nums and vica versa - buran - Oct-24-2018

Welcome to the forum. We are glad to help, but we are not going to do your homework. You need to show your code and ask questions about specific problem you cannot solve on your own. It's good start by googling your problem and research the topic.

Also, this is public forum, feel free to post here, there is no need to contact particular person. This way more people can read and answer your [specific] question


RE: convert words to nums and vica versa - Nimtram - Oct-24-2018

I think I have already told my problem.. :/
I do not know how to read the input. And check if it is the same as in my nums=[]


RE: convert words to nums and vica versa - ichabod801 - Oct-24-2018

(Oct-24-2018, 07:58 AM)buran Wrote: You need to show your code



RE: convert words to nums and vica versa - nilamo - Oct-24-2018

Start small. Handle 0-9, and worry about bigger numbers once that works. Every large project will seem enormously complicated if you always try to do the whole thing all at once.


RE: convert words to nums and vica versa - gruntfutuk - Oct-26-2018

Don't try to write Python. Not at first.

Instead, work out how you would do this yourself if you had to do it in very very basic steps where you can only do one thing at a time, and have very poor memory, so have to have a post-it-note for each and every bit of information you are dealing with. Try it. Use a large surface. Do it physically.

The difficulty most people initially have with figuring out how to tell a computer what to do is that we don't realise just how dumb they are, especially in this modern age of very fancy touch and voice based apps. As humans, we take lots of shortcuts, intuitive leaps, recognise patterns. Computers don't.

Once you've done this, and refined it as a steps you can write down, with lines for loops, you have yourself an algorithm. We can help you then.