I have question regarding for loops and functions, so there list of values which as three input variables which are values for example 0-5 or direction (West, North etc), I am not sure if I using If statement correctly. Have I done something wrong with for loop command or the function?
Example of array input variables but there isn't any set limit in data set:
['Start', 'Bottom right', 1]['South', 1, 1], ['North', 3, 4], ['West', 4, 0], ['West', 2, 0], ['South', 3, 4]
If I run the function, it will always give me else function and won't follow any of commands.
def follow_path(a):
legend() #draw legend
for draw in a:
direction(a[0])
location(a[1])
choosetoken(a[2])
def location(corner):
if corner == 'Top left':
goto(0,600)
if corner == 'Top right':
goto(600,600)
if corner == 'Bottom left':
home()
if corner == 'Bottom right':
goto(600,0)
if corner == 'Center':
goto(300,300)
if corner == 1:
forward(100)
if corner == 2:
forward(200)
if corner == 3:
forward(300)
if corner == 4:
forward(400)
if corner == 5:
forward(500)
else:
print ("Check input '1' is correct or not")
def direction(direction):
if direction == 'West':
setheading(180)
if direction == 'East':
setheading(0)
if direction == 'North':
setheading(90)
if direction == 'West':
setheading(270)
if direction == 'Start':
home()
else:
print ("Check input '0' is correct or not")
def choosetoken(a): #Draw shapes
if a == 0:
youtube()
elif a == 1:
chrome()
elif a == 2:
googledrive()
elif a == 3:
gmail()
elif a == 4:
photo()
else:
print ("Token Value out of range, check if input '2' is correct or not")
Aucun commentaire:
Enregistrer un commentaire