Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn If-Else Statements Practice. Clear the Storage | If-Else Statements
Python Ninja

book
If-Else Statements Practice. Clear the Storage

Your task is to help our ninja clear out all the sushi from a cluttered storage room. The storage room is a grid filled with sushi pieces scattered around, and it's your job to collect them all.

Task

Swipe to start coding

Solution

def ninja_controller(ninja):
for i in range(10):
if ninja.object_right() == "sushi":
ninja.go_right()
ninja.pick_sushi()
else:
ninja.go_right()
if ninja.object_up() == "sushi":
ninja.go_up()
ninja.pick_sushi()
ninja.go_down()
if ninja.object_down() == "sushi":
ninja.go_down()
ninja.pick_sushi()
ninja.go_up()

Explore other courses in Catalog

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 5. Chapter 3
py

ninja.py

def ninja_controller(ninja):
pass
# Write your code below

Ask AI

expand
ChatGPT

Ask anything or try one of the suggested questions to begin our chat

We use cookies to make your experience better!
some-alt