Python-题目:编写一个程序,当输入一个整数时,用英语单词输出该数的每一位数字 例如:输入3567,输出:first_digit second_digit third_digit

  • Post author:
  • Post category:python


"""题目:编写一个程序,当输入一个整数时,用英语单词输出该数的每一位数字
    例如:输入3567,输出:
    first_digit  second_digit third_digit four_digit
        seven        six          five      three
    """

get_num = []
number = input("请输入数字:")
Number = list(range(0, 9))
list_num = [
    'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine',
]

list_num2 = [
    'first_digit', 'second_digit', 'third_digit', 'fourth', 'fifth_digit',
    'sixth_digit', 'seventh_digit', 'eighth_digit', 'ninth_digit', 'tenth_digit'
]

res1 = []
res2 = []

reverse_number = number[::-1]
for i in range(len(number)):
    index = int(reverse_number[i])
    res1.append(list_num2[i])
    res2.append(list_num[index])

print('\t'.join(res1))
print('\t\t'.join(res2))



版权声明:本文为weixin_45880658原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。