S
S
Sergey2020-09-09 01:18:22
Python
Sergey, 2020-09-09 01:18:22

An error in the python parser. game is not defined(((what's wrong here?

Big_dict = {}
BD = {}
shits1 = []

for game in BD.keys():
    for play in BD[game].keys():
    for shitta in shits1:
    count1 += 1
if shitta not in list(BD[game][play].keys()):
    BD[game][play][shitta] = 0
count2 += 1

for key in BD[game][play].keys():
    if key not in Big_dict[game][play].keys():
    Big_dict[game][play][key] = BD[game][play][key]

csv_file = '2.csv'
csv_columns = list(Big_dict[game][play].keys())
with open(csv_file, "w", encoding = 'utf-8') as f:
    writer = csv.writer(f)
writer.writerow(csv_columns)
for key1 in Big_dict.keys():
    for key in Big_dict[key1].keys():
    aux = [Big_dict[key1][key][key2]
        for key2 in csv_columns
    ]
writer.writerow(aux)

csv_file = '3.csv'
with open(csv_file, "w", ) as f:
    writer = csv.writer(f)
writer.writerow(results)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PavelMos, 2020-09-09
@PavelMos

1) Create a question with formatted program text so that indents are visible
2) BD is created as an empty dictionary. Next comes the enumeration of BD keys. But there are no elements in the dictionary, so the game variable, which should contain the value of the next iterated key, is not defined.

Big_dict = {}
BD = {}
shits1 = []

for game in BD.keys():
    for play in BD[game].keys():

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question