I'm new to Python (this is my second language), so hopefully my question can help somebody else also struggling with something similar.
For reference, I'm using Netbeans IDE 6.9.1 and running Python 2.7.3.
A bit of a backstory, I'm studying a transportation problem for thesis, and I need to generate a network of cities (nodes) and roads (arcs). What I'm doing with the code below is generating a string that I'll pass to an open(file,'w') operation, where I'll write randomly-generated data to a text file.
For example: FNodes = '\DijkstraShortestPath\Data\100Nodes\Node5.txt'
I keep getting a "name 'Fnodes' not defined" error when I run this code below.
I've spent hours trying to figure this out; shouldn't this be defined? After all, I did write "FNodes = bla bla bla".
I tried taking it out of the loop, but that brought up the same errors with 'item' and 'replications' since they are used in the FNodes string. This makes sense since they are defined in the for loop.
If you could help a new guy understand this syntax mistake, that'd be great.
Thanks for your help.
R = 10 #Number of replications (trials)
NumNodes = [50,100,150] #Number of nodes (cities). Also the names of 3 folders.
for item in NumNodes: #Cycle through 50, 100, 150 nodes for folder path XXXNodes
for replications in range(R): #Cycle through fileR.txt by replication number
fNodes = "\\DijkstraShortestPath\\Data\\" + str(item) + "Nodes\\Node" \
+ str(replications + 1) + ".txt"
print FNodes #This is a debugging step for me so I can see what's happening
#Write to files and stuff...