I need help in this

Name = input("What is your name: ")
true = input("Do you like a game (Y)es (N)o: ")
Game = command = "" 
while command != "quit" and command != "QUIT":
  command = input(">")
  print("ECHO" , command)
if command == "quit" or "QUIT":
if true == "y":
if true == "n":
  print("I thought you liked a game and I prepared")

This my code and idk why it’s not working fine you can run the code and check it yourself. Please help me out!! I hope to find a solution soon…

Thanks in advance!! :grin:

Hello, there!

There are some issues with your code.

  1. It’s not advisable to use key words (or similar) in your variable names… so true is not a good variable name (the Python boolean is True ). Try using names that give you a better idea of the variable will hold. For this specific case, I’d use something like user_reply , for example. Same goes for command . This is a keyword in Python, so avoid using them.

  2. According to Python PEP, variables should be in lowercase… so Name is not very pythonic. This is to keep style. Code will work no matter how you write it. Check this: How to Write Beautiful Python Code With PEP 8 – Real Python

  3. The Game variable is holding nothing… it’s just an empty string.

  4. Observe that your true variable is holding the user response… that’s the one you have to check in your WHILE loop… but you are not. So, make sure you check the user response to re-direct your code execution.

  5. And this is perhaps your biggest issue: the WHILE loop is only checking ONCE if the player wants to play or not! And you need to make this part of the loop. SO… Here is a small piece of code I just wrote. It’s not complete (use it as a guide). Analize it and modify it as you need…


Let me know how you solve the game, and post it here!