Need Python Dictionary Help?

Sakal

New member
Hello

I need to write all error messages in a python dictionary to a text file.
With my current python code, the text file that it wrote to just displays the dictionary as:

{101: 'Invalid IP Address', 102: 'IP Address Conflict', 103: 'No Connection Can Be Established', 104: 'Connection Time Out', 105: 'Limited or No Connectivity', 106: 'Connected With Limited Access', 107: 'Access Is Denied'}

What is the code to make it display instead:

101 - Invalid IP Address
102 - IP Address Conflict
103 - No Connection Can Be Established
104 - Connection Time Out
105 - Limited or No Connectivity
106 - Connected With Limited Access
107 - Access Is Denied

This is my code:

# Write all Error Messages to a Text File
def enqItem6():
fileName = "errorData.txt"
myFile = open(fileName, "w")
myFile.write(str(errorList))
myFile.close()
print "All Error Messages Have Been Written To", fileName

# Create an empty dictionary
errorList = dict()
# Declare some dictionary items
errorList = {101: "Invalid IP Address",
102: "IP Address Conflict",
103: "No Connection Can Be Established",
104: "Connection Time Out",
105: "Limited or No Connectivity",
106: "Connected With Limited Access",
107: "Access Is Denied"}

Thanks in advance
 
Back
Top