sergeek
так как при правильных данных там всегда будет только один элемент то достаточно будет просто его извлечь добавив в конец
как его извлекать?
sergeek
почему два? у меня одно выводит
а не знаю, у меня вечно все не работает) карма такая! заменила change и second zerro на функции. вся конструкция выглядит так! вроде работает) осталось добавить подсчет процентов, сделать бесконечно возможное количество раз, которые пользователь может ее прокручивать и запихнуть все в файл)
def find_another_zero(dct, first_one):
for key, value in dct.items():
if value == 0 and key != first_one:
return key
def change(dct, first, second, third):
for key,value in dct.items():
if key != first and key != second and key !=third:
return key
import random
count = 3
secondzerro = ''
zerro = ''
abc = {'a':0,'b':0,'c':0}
x = random.choice('abc')
abc[x]=1
print (abc)
choice = input('choose the variable, where 1 is: ')
print('your choice is: ',choice)
if choice in abc.keys():
if abc[choice] == 0:
secondzerro = find_another_zero(abc, choice)
print ('This is a variable, where is 0: ',secondzerro)
if abc[choice] ==1:
zerro = random.choice([key for key in abc.keys() if key != choice])
print('This is a variable, where is 0: ',zerro)
decision = input('Do you want to change your choice? press Y for yes or N for no ')
if decision == 'y':
choice = change(abc,choice, secondzerro,zerro)
print ('your choice is changed to: ', choice)
else:
print ('you entered something wrong')
#continue
if abc(choice) ==1:
print ('win')
else:
print ('you loose')
exit()