I am fairly new to programming, and I am working through the book "Invent Your Own Computer Games with Python". To test that I've understood the chapters, I try to redo whatever game the chapter has been working on and add embellishments without referring to the text for help. I've programmed a certain part differently from the book, but I don't understand why it isn't working.
def chooseletter():
loop = True
playerletter = ""
computerletter = ""
while playerletter not in "X O".split():
playerletter = input("What letter would you like to be? X or O? \n").upper
if playerletter == ("X"):
computerletter = "O"
elif playerletter == ("O"):
computerletter = "X"
else:
loop = True
return [playerletter, computerletter]
For some reason, this code keeps on looping and looping, no matter what I input. When I open the debugger, is says nothing has even been assigned to the variable "playercharacter".
I bet it's something pretty obvious and I'll laugh at myself when someone point out the solution. Thanks for your help.