Hello, I get acquainted with python and after c ++ I categorically do not understand the principle of using global variables. If a variable located in def specify global, is it possible for me to use its value outside this function, I just can't do it. Maybe just because I'm new and the obvious things are still too complicated for me.
def check(): global urokb_in urokb_in = 1 with open('users.txt', 'r') as f: line = f.readline() f.close() with open('progress.txt', 'r') as k: while True: global uroka_in lines = k.readline() if line == lines.rstrip(): uroka_in = int(k.readline().rstrip()) urokb_in = uroka_in + 1 uroka_str = str(uroka_in) urokb_str = str(urokb_in) lines.replace(uroka_str, urokb_str) k.close() break if not lines: k.close() urokb_in = 1 with open('progress.txt', 'a') as j: j.write(line) j.write('\n') j.write(str(urokb_in)) j.write('\n') j.close() break if urokb_in == 1: educate__scr = PhotoImage(file='e_scr_1.png') educate_label = Label(root, image=educate__scr) educate_label.place(x=0, y=0) More experienced coders tell me how to fix it. SyntaxError: name 'urokb_in' is used prior to global declaration
global uroka_inmust be inside a function (immediately afterdef, only once). - insolor