0

How to print the number in words for example: 1234=> One Two Three Four

Using Tuple in Python

19th Jan 2020, 4:59 AM
Gauri Bankar
Gauri Bankar - avatar
2 Respuestas
0
Gauri Bankar I would give you an approach based code try to implement that for work for your purpose with use of spliting input and miltiple input. Not sure if this helps, but it might point you in the right direction:- 1) define an dictionary with 0 to ten number 2) Then in addition when you want to implement the code for multpile inputs you would need a loop: a for loop, a while loop, or a recursive function. with the spliting inputs and then your logic for replacing the number with words and you can use enumeration for that The most problematic part would be to make it print: Enter number: 10 Number Entered: ten num = dict(enumerate(['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'])) #etc x = int(input('Type in a number:- ')) try: print(num[x]) except KeyError: print("No number range.")
19th Jan 2020, 5:33 AM
DishaAhuja
DishaAhuja - avatar
0
1234
23rd Apr 2023, 3:30 PM
Mangal Sabu
Mangal Sabu - avatar