I'm trying to use this code to create a while loop from a string, but it's not working. This is the string that I call with the eval() function:
'while True:\n\vprint("What role do you want?")\n\vAnswer = Reformat(raw_input())\n\vif Answer in RoleArray:\n\v\vPlayArray[0].append(Answer)\n\vif Answer == "Mafia":\n\v\v\vMafia.append(User)\n\v\velif Answer == "Sheriff":\n\v\v\vSheriff = User\n\v\velif Answer == "Doctor":\n\v\v\vDoctor = User\n\v\vdel RoleArray[RoleArray.index(Answer)]\n\velse:\n\v\vprint("That is not a role. Please check you spelling. [Mafia/Sheriff/Doctor/Townsperson]")'
And this is the error that shows up:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
eval('while True:\n\vprint("What role do you want?")\n\vAnswer = Reformat(raw_input())\n\vif Answer in RoleArray:\n\v\vPlayArray[0].append(Answer)\n\vif Answer == "Mafia":\n\v\v\vMafia.append(User)\n\v\velif Answer == "Sheriff":\n\v\v\vSheriff = User\n\v\velif Answer == "Doctor":\n\v\v\vDoctor = User\n\v\vdel RoleArray[RoleArray.index(Answer)]\n\velse:\n\v\vprint("That is not a role. Please check you s')
File "<string>", line 1
while True:
^
SyntaxError: invalid syntax
There is an alternate way to execute this code properly, but I would like to know why it isn't working. Thanks.