这个报错我搞不懂诶,大佬们球球了

用Python模拟羊车门问题来求概率

羊车门问题:有3扇关闭的门,一扇门后停着汽车,另外两扇门后是山羊,主持人知道每扇门后是什么。参赛者首先选择一扇门。在开启它之前,主持人会从另外两扇门中打开一扇门,露出门后的山羊。此时,允许参赛者更换自己的选择。请问,参赛者更换选择后,能否增加猜中汽车的机会?通过设计并编写程序验证,并给出自己的解释。
 

我的代码是

import random
ch_time = 0#change choice time
chr_time = 0#change choice right
nch_time = 0#not change
nchr_time = 0#not change and right
while True:
    door = ['a', 'b', 'c']#三个门
    choice = door[:]#door的复制,方便后面用
    answer = random.choice(door)#随机一个有车的门
    other = door.remove(answer)#剩下的就是有羊的门
    choose1 = random.choice(choice)#随机选一个
    wrong = random.choice(other)#主持人打开的有羊的门
    choose2 = choice.remove(choose1, wrong)#改变选择的话的选择
    if ch_time <= 5000:#if change
        if choose2 == answer:
            ch_time += 1
            chr_time += 1
            continue
        else:
            ch_time += 1
            continue
    else:#if not change
        if choose1 == answer:
            nch_time += 1
            nchr_time += 1
        if choose1 != answer:
            nch_time += 1
        if nch_time >= 5000:
            break
ch_result = chr_time/ch_time
nch_result = nchr_time/nch_time
print(ch_result,nch_result)

但是报错了,报错如下

Traceback (most recent call last):
  File "C:\Users\zyydxjxj\Desktop\zby\操作题\羊车门问题.py", line 12, in <module>
    wrong = random.choice(other)#主持人打开的有羊的门
  File "C:\Users\zyydxjxj\AppData\Local\Programs\Python\Python39\lib\random.py", line 347, in choice
    return seq[self._randbelow(len(seq))]
TypeError: object of type 'NoneType' has no len()
>>> 

我当时心里一万个mmp,诶?nonetype是在搞什么诶!(哭)

所以我就在shell里面逐行尝试代码,尝试的结果如下

>>> import random
>>> door = ['a', 'b', 'c']
>>> choice = door[:]
>>> choice    #确认复制操作没问题
['a', 'b', 'c']
>>> choice.append(1)   #依旧确认
>>> choice
['a', 'b', 'c', 1]
>>> door
['a', 'b', 'c']
>>> choice.remove(1)  #确认完毕(小白嘛,谅解一下嘿嘿)
>>> choice
['a', 'b', 'c']
>>> answer = random.choice(door)   #选正确答案
>>> other = door.remove(answer)   #那剩下的就是错误答案咯
>>> other
>>> print(other)
None    #诶?........#$^%&%$*^$#^$
>>> answer   #搞毛啊,明明answer没错
'c'
>>> other = door.remove(answer)
Traceback (most recent call last):
  File "<pyshell#14>", line 1, in <module>
    other = door.remove(answer)
ValueError: list.remove(x): x not in list  #这说明成功从door里面移除了answer(刚才确认了 
                                              answer只是随机得到的'c'这一项)
>>> #为毛移除了一项就变成了空了啊!!!就算是全部移除也应该是空列表也不是nonetype啊喂!!凸(艹皿艹 )

我的尝试结果还有思考的过程全部在注释里面啦,大佬们球球了!!!!小白无能狂怒

other = door.remove(answer)
door.remove(answer)是一个动作,不返回值的, 所以other 是None
wrong = random.choice(other) 改成 wrong = random.choice(door) 就ok