def check_checi(string):
if string in checi:
return string
else:
y = input("没有该车次,请重新输入要购买的车次:")
return check_checi(y)
type=["车次","出发站-到达站","出发时间","到达时间","历时"]
checi = ["T40","T298","Z158","Z62"] # 车次
chufa = ["长春-北京","长春-北京","长春-北京","长春-北京"] # 出发站-到达站
chushi = ["00:12","00:06","12:48","21:58"] # 出发时间
daoda = ["12:20","10:50","21:06","06:08"] # 到达时间
lishi = ["12:08","10:44","08:18","08:20"] # 历时
print('{} {} {} {} {}'.format(type[0],type[1],type[2],type[3],type[4]))
print('{} {} {} {} {}'.format(checi[0],chufa[0],chushi[0],daoda[0],lishi[0]))
print('{} {} {} {} {}'.format(checi[1],chufa[1],chushi[1],daoda[1],lishi[1]))
print('{} {} {} {} {}'.format(checi[2],chufa[2],chushi[2],daoda[2],lishi[2]))
print('{} {} {} {} {}'.format(checi[3],chufa[3],chushi[3],daoda[3],lishi[3]))
checi = input("请输入要购买的车次:")
checi = check_checi(checi)
xingming = input("请输入乘车人(用逗号隔开):")
if checi==checi[0]:
time=chushi[0]
if checi==checi[1]:
time=chushi[1]
if checi==checi[2]:
time=chushi[2]
if checi==checi[3]:
time=chushi[3]
print('您已购'+checi+'次列车 长春-北京 '+time+"开,请"+xingming+'尽快换取纸质车票。【铁路客服】')