python-长春大学小地图(第二天)

这就是我今天所做的小地图,使用了python 来做。
就是告诉你如何你在长大的门口想去这三个地方(图书馆,足球场,综合楼)往哪里走。by typing “go”+ “方向” you’ll easily get your destination.

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

def showInstructions():
    print('''
长春大学
========
Commands:
  go [direction]
''')
def showStatus():
    print('---------------------------')
    print('您现在在 ' + currentPlace)
    # print an item if there is one
    print("---------------------------")
destination = {
    '正门': {
        'north': '图书馆',
        'east' : '综合楼',
        'west' : '足球场'
            },
    '图书馆': {
        'south': '正门'
             },
 		   '综合楼': {
        'west': '正门'
    },
    '足球场': {
        'east': '正门'
    },
}
currentPlace = '正门'
showInstructions()
while True:
    showStatus()
    move = ''
    while move == '':
        move = input('>')
    move = move.lower().split()
    if move[0] == 'go':
        if move[1] in destination[currentPlace]:
            currentPlace = destination[currentPlace][move[1]]
        else:
            print('您不能往那儿走!!!')

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值