help needed for a game
JJFRENZY (0)

I need help. I need a way for this code to check if the player inputted a, b, c, e, and something not listed and react accordingly.

print("\n" + "Please input your commands a = attack(5) b = block(2) c = counter(1) fill rest with e and type END after you put in all commands.")

#input from User
inputs = [] # list to store the inputs

while True: # looping forever

data = input('Enter command here : ') # read the data from user to variable data

if data == 'END': # if END is read then exit the loop
    break

else:
    inputs.append(data) # otherwise, append the input to the list

print(inputs) # display the list.

You are viewing a single comment. View All
Geocube101 (246)
if command == 'a':
  #Do stuff
elif command == 'b':
  #Do other stuff
elif command == 'c':
  #Do some other stuff
elif command == 'e':
  #Do even more other stuff
elif command == 'END':
  break
else:
  #Do stuff when input is not 'a', 'b', 'c', 'e' or 'END'

"Command" is a string variable equal to whatever the user entered with input
This code goes inside your while loop