Python Forum
convert words to nums and vica versa
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
convert words to nums and vica versa
#1
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.
Reply
#2
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
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=[]
Reply
#4
(Oct-24-2018, 07:58 AM)buran Wrote: You need to show your code
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
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.
Reply
#6
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.
I am trying to help you, really, even if it doesn't always seem that way
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020