سلام،
مشکل داخل آپدیت کردن دیکشنری بود.
from random import randint
import os
class Dict:
Members_Dict = {}
for i in range(1, 51):
Members_Dict[i] = 1
counter = 0
def main():
global counter
while True:
RandomPerson = randint(1, 50)
if Dict.Members_Dict[RandomPerson] == 0:
while Dict.Members_Dict[RandomPerson] == 0:
RandomPerson = randint(1, 50)
Dict.Members_Dict[RandomPerson] -= 1
else:
Dict.Members_Dict[RandomPerson] -= 1
NewRandomPerson = randint(1, 50)
while RandomPerson == NewRandomPerson:
NewRandomPerson = randint(1, 50)
Dict.Members_Dict[NewRandomPerson] += 1
counter += 1
print("Num is: {0}".format(str(counter)))
if Dict.Members_Dict[NewRandomPerson] == 50:
print("Action completed! :D for {0} person".format(NewRandomPerson))
os.system("exit")
if __name__ == "__main__":
main()