+ 1

"Just Say It" SoloLearn List exercise

I am having trouble with the List exercise. I have made multiple attempts to satisfy all conditions, but to no avail, I have failed. I was hoping to get some help from another beginner and simply explain what mistake I was making. My code: https://code.sololearn.com/cA14A21A009A Exercise: https://www.sololearn.com/codecoach/1042?language=py&location=2&source=profile

22nd Feb 2021, 12:16 AM
Matt
16 Antworten
+ 4
Try to solve using if-else statement.
22nd Feb 2021, 12:27 AM
Shivani 📚✍
Shivani 📚✍ - avatar
+ 4
I’m confused as this code outputs the correct respnse but fails the test cases. It works in the playground with no errors. commands = ["Lights Off", "Lock the door", "Open the door", "Make Coffee", "Shut down"] #your code goes here voice = input() if voice in commands: print ("Ok") else: print ("Not Supported")
24th Mar 2021, 7:32 PM
Geoff Ross
Geoff Ross - avatar
+ 2
∆BH∆Y well, I think there's a bug... When I logged in to my Sololearn account in my laptop and clicked the link, it just displays the question! Well, here's the question! List Operations 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 And here's the list! Lights Off, Lock the door, Open the door, Make Coffee, Shut down
22nd Feb 2021, 3:03 AM
TheCoder
+ 2
This worked for me list1 = ['Lights Off', 'Lock the door', 'Open the door', 'Make Coffee', 'Shut down'] input1 = input() if input1 in list1: print('OK') else: print("Not supported")
2nd May 2021, 3:15 PM
Alok Jha
Alok Jha - avatar
+ 2
Geoff Ross, It looks like you may have failed test cases because "Ok" is not set to "OK" as in the instructions. Fixing that should pass all test cases. I know this response is coming months after your post, so you have probably moved on from this question. Either way I hope you were able to remedy the problem and move foward. -Keven
25th Jun 2021, 8:33 PM
Keven Beasley
Keven Beasley - avatar
+ 1
Here is the answer to the project! commands = ["Lights Off", "Lock the door", "Open the door", "Make Coffee", "Shut down"] command = (input)() if command in commands: print("OK") else: print("Not supported")
15th Sep 2021, 8:24 PM
Ben 1
Ben 1 - avatar
0
You can try to iterate the elements in the list and see if the input is in the commands list! commands = ["Lights Off", "Lock the door", "Open the door", "Make Coffee", "Shut down"] i = input() b = False for command in commands: if i == command: b = True if b == True: print("OK") else: print("Not supported") Hope it works! Happy programming :)
22nd Feb 2021, 1:36 AM
TheCoder
0
∆BH∆Y , I ended up looking at your code, and at one point, I had something similar. The only difference was I did not ask for the input. So the variable stayed fixed. I thank you all for the responses! Sincerely, Matt
22nd Feb 2021, 9:35 PM
Matt
0
commands = ["Lights Off", "Lock the door", "Open the door", "Make Coffee", "Shut down"] #your code goes here command = input() if command in commands: print("OK") else: ("Not supported")
11th Mar 2021, 8:58 AM
Amit Rawat
0
commands = ["Lights Off", "Lock the door", "Open the door", "Make Coffee", "Shut down"] #your code goes here x=input() if x not in commands : print("Not supported") else: print("OK")
29th Jun 2021, 11:04 AM
KOW WAI NA
KOW WAI NA - avatar
0
Here is my simple and easy to understand solution: commands = ["Lights Off", "Lock the door", "Open the door", "Make Coffee", "Shut down"] x = input() if x in commands: print("OK") else: print("Not supported")
18th Jul 2021, 2:24 PM
Mark Fernando Maligmat
Mark Fernando Maligmat - avatar
0
I just used if-else statement commands = ["Lights Off", "Lock the door", "Open the door", "Make Coffee", "Shut down"] if "Lights Off" in commands: print("OK") else: print("Not Supported")
4th Sep 2021, 4:11 PM
Lourd Mat Francis Dy
Lourd Mat Francis Dy - avatar
0
i used if and elifs and confirmed that the code still works if you replace elif with else. i just wanted to implement using 'in' and 'not' c=["lights off","lock the door","open the door","make coffee", "shutdown"] cmd=input("command daze: ")) if cmd not in c: print("Not supported") elif cmd in c: print("OK")
13th Sep 2021, 9:54 AM
ajey james kariuki
0
commands = ["Lights Off", "Lock the door", "Open the door", "Make Coffee", "Shut down"] txt = input() if txt in commands: print("OK") else: print("Not supported")
15th Sep 2021, 4:27 PM
Arka Ghosh
Arka Ghosh - avatar
0
""" List Operations 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 """ commands = ["Lights Off", "Lock the door", "Open the door", "Make Coffee", "Shut down"] #your code goes here command = input() if command in commands: print("OK") else: print("Not supported")
18th Feb 2022, 12:49 AM
Jake Ambrose
Jake Ambrose - avatar
0
a=input() commands = ["Lights Off", "Lock the door", "Open the door", "Make Coffee", "Shut down"] if (a in commands ): print ("ok") elif (a not in commands ): print ("not supported")
29th Nov 2022, 1:52 PM
Alazar Abayneh