why is my conditionals statement not working in python

import  random
import  sys 
import os 

print ("what is the password ?") 

instructions  =  ['-Press  [W]  To  Walk  Forward  (-Hold  [Left  Shift]  To Initiate Runing)','-Press [S] To Move Backwards' '-[A] For Left','-[D] For Right','-[space] For Jump']

password  =  sys.stdin.readline() 

if password =='food': 
      print  ("here"  )

for i in instructions: 
    print (i)

else: 
    print  ("not  correct") 

The code I have entered is not working I have been stuck here since yesterday I am trying to learn python but I am stuck here please help me

Upvotes: 0

Views: 117

Answers (2)

Rakmo
Rakmo

Reputation: 1982

in place of

password  =  sys.stdin.readline()

Use following acordingly.

(Python 2)

password = raw_input()

(Python 3)

password = input()

Upvotes: 0

jjislam
jjislam

Reputation: 563

try this:

instructions  =  ['-Press  [W]  To  Walk  Forward  (-Hold  [Left  Shift]  To Initiate Runing)','-Press [S] To Move Backwards' '-[A] For Left','-[D] For Right','-[space] For Jump']

password = input("Enter password")

if password == "food":
      print("here")
      for i in instructions:
          print (i)

else:
    print("not correct")

Upvotes: 1

Related Questions