【网易官方】极客战记(codecombat)攻略-地牢-循环又循环

关卡连接:

https://codecombat.163.com/play/level/loop-da-loop

循环真是救命恩人!

简介:

你只需要 一个 while true循环 加上 4 条语句 就可以通关!

仔细检查你的缩进!

默认代码

# 在 while true 里的代码会永远重复!
while True:
    # 右走
    hero.moveRight()
    # 向上走
    # 左走
    # 向下走

概览

你可以只用一个 while true 循环 以及 4 行命令 就可以存活下来!

确保你加上的代码放在 while true 循环 的 里面。好好检查一下缩进!

循环又循环 解法

# 在 while true 里的代码会永远重复!
while True:
    # 右走
    hero.moveRight()
    # 向上走
    hero.moveUp()
    # 左走
    hero.moveLeft()
    # 向下走
    hero.moveDown()
原文地址:https://www.cnblogs.com/codecombat/p/12085293.html