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
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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?
Thanks for your feedback!
Section 5. Chapter 3
ninja.py
9
1
2
3
4
5
6
def ninja_controller(ninja):
pass
# Write your code below
Ask AI
Ask anything or try one of the suggested questions to begin our chat