从我定义的函数中删除括号

时间:2017-11-07 06:16:49

标签: python python-3.x

当我调用main()函数时,我的输出在它们周围有括号,而我需要它们没有括号。我还需要整数和后面的字母来连接,例如第1,第2,第2021,第15。谢谢!

def int2ordinal(int):
    if int % 10 == 3:
        return (int), 'rd'
    elif int % 10 == 2:
        return (int), 'nd'
    elif int % 10 == 1:
        return (int), 'st'
    else:
        return (int), 'th'

def main():
  day = int(input("Enter a day between 1 and 31: "))
  month = int(input("Enter a month between 1 and 12: "))
  year = int(input("Enter a year between 1 and 2100: "))

  print("On the", int2ordinal(day), "day of the", int2ordinal(month), \
        "month of the", int2ordinal(year), "year, something amazing 
happened!")

main()

0 个答案:

没有答案