0

Apple Of My Eye

my code for the program"Apple of my eye" is running and completing the 3 cases but it is not completing fourth case that is hidden. please find out mistakes. data = [ [23, 11, 5, 14], [8, 32, 20, 5] ] color = input() A=0 total=118 if color=="brown": A=(data[0][0]+data[1][0])+A if color=="blue": A=(data[0][1]+data[1][1])+A if color=="green": A=(data[0][2]+data[1][2])+A if color=="black": A=(data[0][4]+data[1][3])+A B=((A/total)*100) print(int(B))

1st Oct 2021, 10:03 AM
PRAVEEN KUMAR
PRAVEEN KUMAR - avatar
5 Réponses
+ 5
For black, data[0][3]
1st Oct 2021, 10:10 AM
Simba
Simba - avatar
+ 2
Thankyou very much ohhh it was my silly mistakes Simba
1st Oct 2021, 10:14 AM
PRAVEEN KUMAR
PRAVEEN KUMAR - avatar
0
data = [ [23, 11, 5, 14], [8, 32, 20, 5] ] color = input() total = 0 for row in data: total += sum(row) colors = [['brown', 'blue', 'green', 'black'], [0,1,2,3]] x = colors[0].index(color) chosen_people = data[0][x] + data[1][x] print(int(chosen_people*100 / total))
4th Feb 2022, 7:34 AM
Eugenie
0
WHAT IS WRONG WITH MY CODE??? data = [ [23, 11, 5, 14], [8, 32, 20, 5] ] color = input() #your code goes here a=[x[0] for x in data] b=[x[1] for x in data] c=[x[2] for x in data] d=[x[3] for x in data] brown = a blue = b green = c black = d brown_1 = sum(a) blue_1 = sum(b) green_1 = sum(c) black_1 = sum(d) listSum = [sum(x) for x in data] listSum2 = sum(listSum) if color == a : print (int((brown_1/listSum2)*100)) elif color == b : print (int((blue_1/listSum2)*100)) elif color == c : print (int((green_1/listSum2)*100)) elif color == d : print (int((black_1/listSum2)*100))
21st Oct 2022, 12:06 PM
stefano sartori
stefano sartori - avatar
0
data = [ [23, 11, 5, 14], [8, 32, 20, 5] ] colordict = { "brown": 0, "blue": 1, "green": 2, "black": 3 } color = input() #your code goes here totNrPeo = (sum(data[0]))+(sum(data[1])) colorNrPeo = (data[0][(colordict[color])])+(data[1][(colordict[color])]) print (round(colorNrPeo/totNrPeo*100))
8th Dec 2022, 9:49 PM
Laurent