I have 2 python files. In file1, a list named MyList is created and in file2, the goal is to only print MyList from file1. In file2 I have the code below but it executes all of file1 along with the print function from file2.
#CODE FOR FILE 2
#/usr/bin/python
from file1 import MyList
print MyList
How do I prevent it from executing the commands in file1?
The code for file 1 is as follows:
MyList={}
UserListName = str(raw_input("Provide a name for your list: "))
MyList[UserListName]=[]
print "The userlist name is ", MyList
#feed values into MyList[UserListName] using raw_input
q = int(raw_input("Specify quantities for your list: "))
ArbitValue = 0
while ArbitValue < q:
MyList[UserListName].append(raw_input("Enter value: "))
ArbitValue += 1
print "The values entered in ", MyList