total = {}
count = 0
while(count < 4):
_input = input()
count = count + 1
total[_input] = 0
for i in range(5):
_input2 = int(input())
total[_input] = total[_input] + _input2
print(total)
Virat,101,88,93,0,120
Rohit,50,100,30,140,80
Sky,10,20,30,40,50
Shreyas,100,0,0,100,0
Expected output:
{'Virat': 402, 'Rohit': 400, 'Sky': 150, 'Shreyas': 200}
The code works perfectly fine on my system, but it shows error
ValueError: invalid literal for int() with base 10
where I am solving questions
I checked your code running fine if you give input one by one. Like,
If you want to give input like
Virat,101,88,93,0,120, It stores value like{'Virat,10,20,30,40,50': 0}And second input is '' and when it doesint('')it will throw:ValueError: invalid literal for int() with base 10: ''But if you want to give input like
Virat,101,88,93,0,120, below is modified code:Where you can give input same as you displayed:
And get output like:
{'Virat': 402, 'Rohit': 400, 'Sky': 150, 'Shreyas': 200}