def Input():
c = raw_input ('Enter data1,data2: ')
data = c.split(',')
return data
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?
Add the global keyword to your function:
The
global datastatement is a declaration that makesdataa global variable. After callingInput()you will be able to refer todatain other functions.