The question is that the solution resulting in float rather than integers. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

The question is that the solution resulting in float rather than integers.

data = [ [23, 11, 5, 14], [8, 32, 20, 5] ] color = input() #your code goes here total= 23+11+5+14+8+32+20+5 if color=="brown" or color=="blue" or color=="green" or color=="black": print(int((data[0][0]+data[1][0]))*100/total)

12th Dec 2022, 2:05 PM
Haris
3 Answers
+ 5
Haris , there are issues that need your attention. please have look in the attached file with your code, and also some comments and hints. > it is recommended to read the task carefully. https://code.sololearn.com/cbWT0f5dbj5L/?ref=app
12th Dec 2022, 3:53 PM
Lothar
Lothar - avatar
+ 2
In python, division results in a float. You need to convert float to int: a = int(data([0][0]+data[1][0])) * 100 / total int(a) print(a) I could make a mistake, but I think you understand the principle
12th Dec 2022, 2:54 PM
Knight
Knight - avatar
+ 2
thank you for that.. But in this case my code works like this.. and only single case is solved! data = [ [23, 11, 5, 14], [8, 32, 20, 5] ] color = input() #your code goes here total=23+11+5+14+8+32+20+5 if color=="brown" or color=="blue" or color=="green" or color=="black": a = (data[0][0]+data[1][0]) * 100 / total print(int(a)) # end
12th Dec 2022, 3:40 PM
Haris