Reputation: 11
I'm writing this section of the program to have the user to list how many calories they're planning on eating per day of their diet, subtract it from their tdee, and then divide it by the number of calories in a kg of weight loss.
I keep getting this error:
line 110, in <module>
custom_cals = int(input())
ValueError: invalid literal for int() with base 10: '2000, 2200, 2000'
The "2000, 2200, 2000" from the error are test inputs I just did by the way.
elif diet == 'custom' and sex == 'male':
print('write each daily intake followed by a comma like so: 2200, 2500, 2000')
custom_cals = int(input())
custom_array = num.array(custom_cals)
custom_weightloss = (num.sum(custom_array) / 7716.1805)
print('according to my calculations, you will lose ' + str(custom_weightloss) + 'kgs doing this diet!')
Upvotes: 0
Views: 108
Reputation: 2162
Just look at custom_cals = int(input())
line of code and you are passing this kind of input 2000, 2200, 2000
. But int
take input a string literal that can be converted into int datatype
. For more details check out this link.
Change this code to:
custom_cals = int(input())
To:
custom_cals = list(map(int, input()))
Upvotes: 1