-3
e1 = input("Enter Ingredient 1: ")
e1o = input("How Many Ounces Of " + e1 + ':')
e2 = input("Enter Ingredient 2: ")
e2o = input("How Many Ounces of " + e2 + ':')
e3 = input("Enter Ingredient 3: ")
e3o = input("How many ounces of " + e3 + ':')
serve = input('How Many Servings?: ')

print('Total ounces of ' + e1 + ': ' + str(serve * e1o))
print('Total ounces of ' + e2 + ': ' + str(serve * e20))
print('Total ounces of ' + e3 + ': ' + str(serve * e3o))

The errors I'm getting are:

Traceback (most recent call last):
  File "main.py", line 9, in <module>
    print('Total ounces of ' + e1 + ': ' + int(str(serve * e1o)))
TypeError: can't multiply sequence by non-int of type 'str'
John Kugelman
  • 349,597
  • 67
  • 533
  • 578

1 Answers1

0

When you use the input() method in python to take input from the user, it will take all input as a string. You then try to multiple 2 string together, make sure you cast the strings to numbers before applying the math operator to them like below:

print('Total ounces of ' + e1 + ': ' + str(int(serve) * int(e1o)))
print('Total ounces of ' + e2 + ': ' + str(int(serve) * int(e2o)))
print('Total ounces of ' + e3 + ': ' + str(int(serve) * int(e3o)))
Jason Gerard
  • 106
  • 1
  • 5