Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
10-12-2011, 09:57 PM #1
- Join Date
- Oct 2011
- Thanked 0 Times in 0 Posts
Need help with python control structures.
I'm currently taking a computer science class in my high school and right now we are working with a program called jeroo and are starting with the python language. We got through the basics and methods and now we are learning control structures. In the assignment we're doing now we have to "connect the dots". It checks to see if a flower is ahead and if there isn't it hops and plants a flower. And if there is a flower to the left or right it turns and continues checking for flowers. But my problem is we have to make it work for two different maps. I need to know if there is a way to loop a method without typing it in the main method over and over. For example:
def a(self): while not self.isFlower(AHEAD) self.hop() self.plant() self.hop()Code:
if self.isFlower(LEFT) and self.isFlower(RIGHT)