0

For my CS class in school i need to print feet next to inches and i keep getting the error

"TypeError: unsupported operand type(s) for Add: 'int' and 'str' on line 10" 

I hope someone can help

x = float(input('Enter the Feet: '))
y = float(input('Enter the Inches: '))
a = float(input('Enter the Feet: '))
b = float(input('Enter the Inches: '))
ftoin1 = float(x * 12)
ftoin2 = float(a * 12)
final = (int(ftoin1 + int(ftoin2)  + int(y) + int(b)))
final2 = (int(final) // 12)
final3 = (int(final) % 12)
print(str('Feet: '), + int(final2) + ('Inches: '), + int(final3))
  • Missing parenthesis: `int(ftoin1 + int(ftoin2)`, and why do you have `+` in your print statement after commas? – OneCricketeer Oct 13 '20 at 21:52
  • To concatenate, You need to convert int to str in last line, not vise versa. – A.B Oct 13 '20 at 21:53
  • You don't need to call `str()` and `int()` when the argument is already of the type you want. – Barmar Oct 13 '20 at 21:53
  • You really shouldn't concatenate at all https://pyformat.info/ – OneCricketeer Oct 13 '20 at 21:54
  • Hello, you cannot concatenate `str` with `int`. So in the last line you should remove `+` operator. Check this out:`print(str('Feet: '), int(final2), ('Inches: '), int(final3))` Also you can remove some of the parenthesis because some of them are useless in fact. – Saeed Oct 13 '20 at 21:55

0 Answers0