def getEntries():
# Loop variables, etc
loopNum = 1
setupString = ''
entryData = []
# Loop will go through all our entry boxes in our grid
# For each row, we will get the data and build our string and then append it to
for entry in my_entries:
if loopNum % 5 != 0:
# Update our string
setupString += entry.get() + ' '
else:
setupString += entry.get()
entryData.append(setupString)
#reset our loopstring
setupString = ''
# increment our loopNum
loopNum += 1
print(entryData)
generateScript(entryData)
def generateScript(myList):
fileName = ent_script_name.get()
# Create our nested dictionary
nested_dict = {}
# Loop through our list
for line in myList:
# Specify that we want decimal with 3 percision
decimal.getcontext().prec = 3
# Split our line and get our parts
parts = line.split()
print(parts)
state = parts[0] # Remove trailing comma
amount = int(parts[1])
rate = decimal.Decimal(parts[2])
value = decimal.Decimal(parts[3])
category = parts[4]
print(f'Getting part 4 {parts[4]}')
nested_dict[state] = {
'amount': amount, # highest amount of insurance from rate sheet
'rate': rate, # each add'l factor from rate sheet
'value': value, # factor for amount
'category': category # 'A' or 'H'
}
printed out some debug statements to see the resulting dictionary
Have two python lists in which I want to add them to a nested dictionary. When I print out the resulting dictionary I see the second entry but for some reason it skips the first entry