Assuming you have Python 3, I'll answer you first. Why does it print 4?
You print the 4 by the input, the input prints in the console and receives a variable of the same. If you press enter after the 4 is shown, the 8 will be printed also by the other input of this line elif str(input("8")):
and if you press enter again the program will end.
To give an answer to your problem, as you were told, you do not make any comparison:
number = 4
guess = 8
numeroIngresado=int(input("Ingresa un numero"))
if numeroIngresado==number:
print("Seleccionaste el numero menor")
elif numeroIngresado==guess:
print("Seleccionaste el numero mayor")
Another way to do it (not recommended):
number = '4'
guess = '8'
numeroIngresado=input("Ingresa un numero")
if numeroIngresado==number:
print("Seleccionaste el numero menor")
elif numeroIngresado==guess:
print("Seleccionaste el numero mayor")
The program that you seem to be trying to do, a loop can improve this program.
guess = '4'
print("Adivina el numero")
numeroIngresado=input("Ingresa un numero: ")
if numeroIngresado < guess:
print("El numero ingresado es menor")
elif numeroIngresado > guess:
print("El numero ingresado es mayor")
elif numeroIngresado==guess:
print("Adivinaste el numero")