-3

enter image description here in the image please see the option c . I need a program in python.

enter image description here

I was trying to print number in word but I didn't get successful. I want a answer in python.

Anand
  • 7
  • 3
  • Please [don’t post images of code, error messages, or other textual data.](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question/285557#285557) – tripleee Feb 12 '23 at 09:25

1 Answers1

1
def int_to_word(character):
  character = str(character) if type(character)!=str else None
  conversion_dict = {
    '1': 'ONE',
    '2': 'TWO',
    '3': 'THREE',
    '4': 'FOUR',
    '5': 'FIVE',
    '6': 'SIX',
    '7': 'SEVEN',
    '8': 'EIGHT',
    '9': 'NINE'
  }
  return conversion_dict[character] if character.isnumeric() else 'Character not numeric'

This should work if the user inputs the number as a string or integer data type. If you can control the data type input you would just delete the second line, and make sure the input character data type was in a string format.

For example, to use:

print(int_to_word(6))
print(int_to_word('7'))

output:

SIX
SEVEN
  • How to ask a number form user in this program. – Anand Feb 09 '23 at 05:12
  • Ask the user for the number as a string data type. If that complicates things, you could just add: – Jamie Dormaar Feb 09 '23 at 05:35
  • please can u tell me how to add – Anand Feb 09 '23 at 05:37
  • hmm editing comments are odd, I'll add it to the answer instead, one sec – Jamie Dormaar Feb 09 '23 at 05:41
  • 1
    `type(character)!='str'` will always be true as `type` doesn't return strings... – Tomerikoo Feb 12 '23 at 09:14
  • @JamieDormaar Please read the close reasons on this question. In brief, questions should be self-contained and not rely on pictures of code or on offsite pages. There is more on the [help] pages explaining what is expected of questions (also of answers) on this site. – AdrianHHH Feb 12 '23 at 09:29
  • @AdrianHHH Hi Adrian, thanks for your message. I'm still new here so I appreciate the feed back. This question was actually not yet closed at the time I answered, but do you know if we should we follow up on our answers and withdraw any answers posted once questions become closed? – Jamie Dormaar Feb 13 '23 at 21:20
  • 1
    Hello @JamieDormaar, I would leave your answer alone. The question is now closed so will not get additional updates or answers, unless the question asker updates the question and it gets reopened. Then your answer may well be useful and (still) be correct. My suggestion is that you avoid answering bad questions as they waste your time. Focus on well written questions in topics you know. Avoid repeating existing answers. Learning the rules of this website take a while, the [help] pages are good. – AdrianHHH Feb 13 '23 at 22:08