-2
A = raw_input("5 + 5 =")

if A == 10:
    print "$"
elif A <> 10:
    print "!"

when I input 10 I also get "!" why?

Wolfie
  • 27,562
  • 7
  • 28
  • 55
WildFire
  • 79
  • 1
  • 9

2 Answers2

3

raw_input returns a string, so you're getting back "10" (according to my terminal).

10 == '10' yields false. You need to cast the input to a number.

A = int(raw_input("5 + 5 ="))
Sterling Archer
  • 22,070
  • 18
  • 81
  • 118
1

Because the result of your call to raw_input is a string, not an integer.

You are comparing 5+5 == "10", which is false.

Trying using the int("str") function to convert your input to a number.

aghast
  • 14,785
  • 3
  • 24
  • 56