0

I wanted to call a string from another class and compare whether the string value match from the define string in the variable. But when runing the code it doesn't compare properly.Thanks for the reply.

class TasteMaker:
   
    print(" Nice! Now your maggie is half cooked, it's time to add the taste maker. "
          " \n Taste maker is the flavour of maggie and it is recommended to add it"
          " but some people keep it simple without adding it. "
          "\n So want to add or not add the taste maker. " " \n A.add \n B.don't add ")
    time.sleep(3)
    taste = input(" >>> ").lower()


class Time:
    

    minutes = TasteMaker.taste
    addY = ['add', 'A']

    if minutes == addY:
        print("Nice Choice!")
        time.sleep(2)
        print("\n Now for the final touch. The last and the first step is the most crucial step in cooking."
              " Chose whether to keep in for full 10min, 15min or 20min"
              "\n A.10min"
              "\n B.15min"
              "\n C.20min")
        final = input(" >>> ")

    else:
        print(" Ok! You chose not to add the taste maker.")
        time.sleep(2)
        print("\n Now for the final touch. The last and the first step is the most crucial step in cooking."
              " Chose whether to keep in for full 10min, 15min or 20min"
              "\n A.10min"
              "\n B.15min"
              "\n C.20min")
        final = input(" >>> ")
ShadowRanger
  • 143,180
  • 12
  • 188
  • 271
Dummy Bot
  • 1
  • 1
  • 1
    Why do you have classes here where you make no instances of them, and they don't have any methods? It seems like you have a basic misunderstanding of the purpose of classes... – ShadowRanger Nov 13 '20 at 16:08
  • i am sorry i am learning by myself and got started..can u explain how can i compare string in the if statement when the variable is define. – Dummy Bot Nov 13 '20 at 16:17
  • Per the duplicate, seems like you just want to change `if minutes == addY:` to `if minutes in addY:`. Not that `minutes` or `addY` make any sense as variable names. – ShadowRanger Nov 13 '20 at 16:18
  • i tried using == but the if function doesn't call rather else is called..so iam confused is there any other way around it – Dummy Bot Nov 13 '20 at 16:19
  • You're not reading what I wrote. I didn't say to use `==`. – ShadowRanger Nov 13 '20 at 16:23
  • I am so SORRY! I was just lost trying to find the solution.. It worked.. the "in" that's the key word i was searching for not "is" or "=="..Thank you big time..and again i am really sorry – Dummy Bot Nov 13 '20 at 16:40

0 Answers0