how to make variable global in python
global variable
variable = 'whatever'
how to make variable global in python
global variable
variable = 'whatever'
global variable python
#it is best not to use global variables in a function
#(pass it as an argument)
a = 'This is global a'
def yourFunction():
global a
return a[0:2]
how to acess global variables within function python
#A global variable can be accessed from any function or method.
#However, we must declare that we are using the global version and not the local one.
#To do this, at the start of your function/method write "global" and then the name of the variable.
#Example:
myVariable = 1
def myFunction():
global myVariable
print(myVariable)
myFunction()
global var in python
a = input('Hello: ')
if a == 'world':
global b
b = input('Here')
print b
#Prints the input for be as a result
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us