SyntaxError: name 'cows' is assigned to before global declaration in Python3.6
问题 I am trying to edit the global variables cows and bulls inside a loop but getting this error "SyntaxError: name 'cows' is assigned to before global declaration" import random random_no = random.sample(range(0, 10), 4) cows = 0 bulls = 0 #random_num = ','.join(map(str, random_no)) print(random_no) user_input = input("Guess the no: ") for index, num in enumerate(random_no): global cows, bulls print(index, num) if user_input[index] == num: cows += 1 elif user_input[index] in random_no: bulls +=