I need help. I created a code to make 5 shapes to go to a given place (one shape
ID: 3744284 • Letter: I
Question
I need help. I created a code to make 5 shapes to go to a given place (one shape can go to more than one place) however after going to the place i have to count all the shapes at the places. I was able to count the total number of shapes however i couldn't count how many of shape_1 was there (how many of shape_2, how many of shape_3 and so on). please really want this to work. THank you
def follow(map):
drawgrid()
counter = 0
count_1 = 0
count_2 = 0
count_3 = 0
count_4 = 0
count_5 = 0
for direction in map:
if direction[0] == 'Start':
start_pos(direction)
token_being_drawed(direction)
counter = counter+1
if direction[0] != 'Start':
place(direction)
move(direction)
token_being_drawed(direction)
counter = counter+1
#tried to count the total number of each shape but doesn't work
if token_being_drawed(direction) == 0: #i have defined each shape to a number 0 means shape one also they have a name shape_1
count_1 = count_1 + 1
if token_being_drawed(direction) == 1: #shape_2 or 1 and so on with the other
count_2 = count_2 + 1
if token_being_drawed(direction) == 2:
count_3 = count_3 + 1
if token_being_drawed(direction) == 3:
count_4 = count_4 + 1
if token_being_drawed(direction) == 4:
count_5 = count_5 + 1
print(count_1)
print(counter)
print(count_2)
print(count_3)
print(count_4)
print(count_5)
Explanation / Answer
please check this : --------------------->>>>>>>>>>
def follow(map):
drawgrid()
counter = 0
count_1 = 0
count_2 = 0
count_3 = 0
count_4 = 0
count_5 = 0
tc = 0
for direction in map:
if direction[0] == 'Start':
start_pos(direction)
tc = token_being_drawed(direction)
counter = counter+1
if direction[0] != 'Start':
place(direction)
move(direction)
tc = token_being_drawed(direction)
counter = counter+1
#tried to count the total number of each shape but doesn't work
if tc == 0: #i have defined each shape to a number 0 means shape one also they have a name shape_1
count_1 = count_1 + 1
elif tc == 1: #shape_2 or 1 and so on with the other
count_2 = count_2 + 1
elif tc == 2:
count_3 = count_3 + 1
elif tc == 3:
count_4 = count_4 + 1
elif tc == 4:
count_5 = count_5 + 1
print(count_1)
print(counter)
print(count_2)
print(count_3)
print(count_4)
print(count_5)
#if it will not work please provide all function which you define
#and comment in comment section