0

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!')

1 Answer 1

1

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()))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.