+ 1
[SOLVED] Python: How can I make this work?
The problem is on line 3 of my code. I'm trying to get input from the user, and have my code check if that input is in the dictionary guns. from there I just want my code to print the user_resp. I'm just trying to get the mechanic down so I can use this technique in my other code. Any help is appreciated :D guns = ["pistol", "sniper", "rocket launcher"] user_resp = raw_input("") if user_resp == str in guns: print user_resp
4 Answers
+ 7
Sololearn uses Python3 interpreter, while your code is clearly written in Python2. Also, the syntax is even easier than you think ;)
Your code, in order to work here should go like:
guns = ["pistol", "sniper", "rocket launcher"]
user_resp = input()
if user_resp in guns:
print(user_resp)
+ 2
thank you all! :)
+ 1
use
if user_resp in guns:
0
try this
if user_resp in guns: