我正在为多选游戏构建一个随机名称生成器,我需要知道如何使用户输入更改用于选项本身的变量。
这是我的代码:
main_name = 'William'
while True:
if main_name == 'William':
print ("Welcome to your life",main_name,". \n"
"As you are an intelligent baby, you decide to call yourself,\n"
" A. William \n B. Will \n C. Bill \n D. Billy")
if input() in ['A','a','B','b','C','c','D','d']:
break
if input() == 'A' or 'a':
main_name = 'William'
if input() == 'B' or 'b':
main_name = 'Will'
if input() == 'C' or 'c':
main_name = 'Bill'
if input() == 'D' or 'd':
main_name = 'Billy'
将感谢您的帮助:)谢谢