0

Why doesn’t this code work

import datetime import os class BOPA: def __init__(self, des): self.des = des class Shutoffpcs(BOPA): def ID(self): os.system("shutdown/i") class Date(BOPA): def ID(self): date_object = datetime.date.today() print(date_object) SOPCS = Shutoffpcs("1") DATE = Date("3") while True: ip = input(": ") if ip == "shutdown other pc" or "Shutdown other pc": SOPCS.ID() elif ip == "what is the date today" or "What is the date today": DATE.ID() This code keeps giving me the shutdown option when I’m trying to use the date one. Pls help

6th Mar 2020, 3:43 AM
Really Cool Man
Really Cool Man - avatar
2 odpowiedzi
+ 3
Try changing this while True: ip = input(": ") if ip == "shutdown other pc" or "Shutdown other pc": SOPCS.ID() elif ip == "what is the date today" or "What is the date today": DATE.ID() To while True: ip = input(": ") if ip == "shutdown other pc" or ip == "Shutdown other pc": SOPCS.ID() elif ip == "what is the date today" or ip == "What is the date today": DATE.ID() I think the problem is in the if-elif conditions.
6th Mar 2020, 4:57 AM
Utkarsh Sharma
Utkarsh Sharma - avatar
+ 1
When you want to check that a variable is one of several possible values, you can also use the 'in' operator if var in ('this', 'that', 'something'):
6th Mar 2020, 6:02 AM
Tibor Santa
Tibor Santa - avatar