Задачата е следната:
Digit as Word
Description
Write a program that read a digit [0-9] from the console, and depending on the input, shows the digit as a word (in English).
- Print “not a digit” in case of invalid input.
- Use a switch statement.
Input
- The input consists of one line only, which contains the digit.
Output
- Output a single line - should the input be a valid digits, print the english word for the digits. Otherwise, print “not a digit” .
Constraints
- The input will never be an empty line.
Sample tests
Input | Output |
---|---|
-0.1 | not a digit |
1 | one |
9 | nine |
-9 | not a digit |
kek | not a digit |
А кодът който съм написал е:
a = input()
match a:
case '1':
print('one')
case '2':
print('two')
case '3':
print('three')
case '4':
print('four')
case '5':
print('five')
case '6':
print('six')
case '7':
print('seven')
case '8':
print('eight')
case '9':
print('nine')
case _:
print('not a digit')
Доста straight forward, и когато го рън-вам работи, но Judge дава инвалид ретърн, какъв е проблемът?