Python issue gave up around 4am
Question: program that requests four number (integer or floating-point) from the user.
your program should compute the average the first three numbers and compare
the average to the fourth. if they are equal, your program should print
'Equal' on the screen.

    
    
    import math
    x1 = input('Enter first number: ')
    x2 = input('Enter second number: ')
    x3 = input('Enter third number: ')
    x4 = input('Enter fourth number: ')
    
    if ( x4 == (x1 + x2 + x3) / 3):
        print('equal')
    

Error message:

    
    
    if ( x4 == (x1 + x2 + x3) / 3):
    TypeError: unsupported operand type(s) for /: 'str' and 'int'" 
    

second error message after trying to convert to int:

x1 = int(input('Enter first number: ')) ValueError: invalid literal for int()
with base 10:


Answer: You are using mathematical operands on strings. Here is your fix:

    
    
    import math
    x1 = int(input('Enter first number: '))
    x2 = int(input('Enter second number: '))
    x3 = int(input('Enter third number: '))
    x4 = int(input('Enter fourth number: '))
    
    if ( x4 == (x1 + x2 + x3) / 3):
        print('equal')
    

You simply have to cast the strings to int.

