JavaScript
x
5
1
def Input():
2
c = raw_input ('Enter data1,data2: ')
3
data = c.split(',')
4
return data
5
I need to use list data
in other functions, but I don’t want to enter raw_input
everytime. How I can make data
like a global static in c++ and put it everywhere where it needed?
Advertisement
Answer
Add the global keyword to your function:
JavaScript
1
6
1
def Input():
2
global data
3
c = raw_input ('Enter data1,data2: ')
4
data = c.split(',')
5
return data
6
The global data
statement is a declaration that makes data
a global variable. After calling Input()
you will be able to refer to data
in other functions.