0
Non integer of type?
Trying to find the average of a group of numbers. Googled solutions (which looks nice) but get the following error message: Traceback (most recent call last): File "..\Playground\", line 4, in <module> print('Percent of X: '+str(X*Z)+'%') TypeError: can't multiply sequence by non-int of type What do they mean by "non integer of type"? X = input() Y = input() Z = 100/(int(X)+int(Y)) print('Percent of X: '+str(X*Z)+'%') print('Percent of Y: '+str(Y*Z)+'%') https://code.sololearn.com/c93cQeuPa5j0/#py
2 Answers
+ 2
input() always returns a string. You need to convert these to floats (or integers) to do mathematical operations.
X = float(input())
Y = float(input())
Z = 100/(int(X)+int(Y))
print('Percent of X: '+str(X*Z)+'%')
print('Percent of Y: '+str(Y*Z)+'%')
0
Thanks, Russ!