Train_stations = [ "Perrache", "Ampere", "Bellecour", "Cordeliers", "Louis", "Massena" ]
我开始这样做:
start_station = input("Where are you now?")
ending_station = input("Where would you like to go,")
final = range(start_station) - range(ending_station)
print(final)
它不起作用,因为显然我不能使用这种类型的值来设置用户范围
如何获取列表中事物的索引差异:使用the ^{} method :
输出:
如果目标是获得站
indexes
之间的距离,则只需使用.index()
并取差的abs()
相关问题 更多 >
编程相关推荐