0

Why do I get an error

The task : You’re making a voice recognition system. The supported commands are stored in a list. Complete the program to take a command as input, check if it’s supported and output "OK", if it is, and "Not supported", if not. Sample Input Lights Off Sample Output OK My code : commands = ["Lights Off", "Lock the door", "Open the door", "Make Coffee", "Shut down"] x= str(input) if x == commands : print ("Ok") else: print ("Not supported")

11th Apr 2023, 11:46 AM
mazen mohamed
mazen mohamed - avatar
5 Respuestas
+ 4
mazen mohamed x = str(input) - What is this? By default, the input() function already returns a string value. if x in commands: # not == Sample Output: OK You have: print("Ok")
11th Apr 2023, 12:20 PM
Solo
Solo - avatar
+ 1
mazen mohamed That's because you made a bunch of mistakes in such a short code.
11th Apr 2023, 12:57 PM
Solo
Solo - avatar
+ 1
Hi, mazen mohamed ! You call the builtin function input (and all other functions) with parathesis at the end, like x = input() You can use ’in’ to check membership, like val in my_list to check if the value in the variable val is in the list my_list.
11th Apr 2023, 5:44 PM
Per Bratthammar
Per Bratthammar - avatar
+ 1
Hi , Per Bratthammar Thanks a lot I did it Thanks 🙏
11th Apr 2023, 7:36 PM
mazen mohamed
mazen mohamed - avatar
0
Thanks 🙏 But it's the same result Give me not supported Not Ok
11th Apr 2023, 12:44 PM
mazen mohamed
mazen mohamed - avatar