0

The variable C won't run in the following code:

A = raw_input("How are you today")
if A == "Good" or "Fine" or "good" or "fine" or "great" or "Great" or "Wonderful" or "wonderful":
  print("I am glad you are having a good day")
    B = raw_input("What made your day good")
    if B == "everything" or "Everthing":
        print("Everything! You must be having a very good day")
    else:
        print("It sounds like you had a very intersting day")

        C = raw_input("Do you want to hear about my day? [y/n]")
        if C == "y" or "Y":
            print("I sat around as an unused computer!")
        else:
            print("I guess I am just an annoying computer")
else:
    print("I am sorry you are having a bad day")
awesoon
  • 32,469
  • 11
  • 74
  • 99
  • 2
    Possible duplicate of [How do I test one variable against multiple values?](http://stackoverflow.com/questions/15112125/how-do-i-test-one-variable-against-multiple-values) – Two-Bit Alchemist Jul 06 '16 at 14:18
  • 1
    Please format your code properly for your next StackOverflow question. It's impossible to debug Python with improper indentation. In this case it's easy to see what's happened because you've made a very common mistake. Please see the linked question for your answer. – Two-Bit Alchemist Jul 06 '16 at 14:18
  • The last `else` statement has no corresponding `if`. – Hamid Rouhani Jul 06 '16 at 14:27

2 Answers2

0

you are making the compare as you say it while it should be always A == X or A== Y and so on

another way to make you type less is to use in operator in list.

like this

A = "Wonderful"
if A in ["Good","Fine","good","fine","great","Great","Wonderful","wonderful"]:
    print "yes"
else:
    print "no"

that will make you type less and have the same results instead of repeating A==X for every case

you have to do that for all variables A,B and C

Hani
  • 1,354
  • 10
  • 20
-1

You have to compare every time in the if statement. Suppose you are trying to do this:

>>> b = "bhansa"
>>> if b== "A" or "B":
    print "yes"


yes

Which is not true.

A = raw_input("How are you today")
if A == "Good" or A=="Fine" or A=="good" or A=="fine" or A=="great" or A=="Great" or A=="Wonderful" or A=="wonderful":
  print("I am glad you are having a good day")
  B = raw_input("What made your day good")
  if B == "everything" or B=="Everthing":
    print("Everything! You must be having a very good day")
  else:
    print("It sounds like you had a very intersting day")
    C = raw_input("Do you want to hear about my day? [y/n]")
    if C == "y" or C=="Y":
      print("I sat around as an unused computer!")
    else:
      print("I guess I am just an annoying computer")
else:
  print("I am sorry you are having a bad day")
bhansa
  • 7,282
  • 3
  • 30
  • 55