global tag

2 questions


1 answers
109 views
0
I want to change the baseball game to a function, is there any other way to use global?

Below is a baseball game that I have madeimport random answer = random.sample(range(1,10),3) tr_num = 0 # Variable indicating how many attempts have been madevariable representing the number of st...


1 answers
103 views
0
Ask questions about using the python global keyword. Why can you refer to function external variables when you do not declare global?

I'm practicing implementing the Fibonacci sequence using a recursive function dic = {1: 1, 2: 1}def pibo(n): if n in dic: return dic[n] else: out = pibo(n-1) + pibo(n-2) dic[n] = out return out...

1 years ago

© 2024 OneMinuteCode. All rights reserved.