Help with Python debug
CODE STARTS BELOW-----------------------------------------------------------------
import sys HostAddress =range(10000) HostName =range(10000) HostThreshold =range(10000) HostAlarmLevel =range(10000) HostDataSend =range(10000) index = 0 while True: HostAddress[index] = raw_input("Enter IP Address: ") HostName[index] = raw_input("Enter host name: ") HostThreshold[index] = raw_input("Enter threshold: ") HostAlarmLevel[index] = raw_input("Enter alarm level (1-5 5 being most critical): ") HostDataSend[index] = raw_input("Store data for this host? (yes or no): ") index += 1 Option1 = raw_input("Quit? (y/n): ") if Option1 == 'y': break counter = index index = 0 CCConfigFile = open("connectcheck.cfg", "w") while index <= counter: CCConfigFile.write(str(HostAddress[index] + "\n")) CCConfigFile.write(str(HostName[index] + "\n")) CCConfigFile.write(str(HostThreshold[index] + "\n")) CCConfigFile.write(str(HostAlarmLevel[index] + "\n")) CCConfigFile.write(str(HostDataSend[index] + "\n")) index += 1 CCConfigFile.close() CODE ENDS----------------------------------------------------------------------------- When I run this script everything works fine. The file is written as intended, yet I still keep getting this error message: Traceback (most recent call last): File "connectcheck-setup.py", line 29, in ? CCConfigFile.write(str(HostAddress[index] + "\n")) TypeError: unsupported operand type(s) for +: 'int' and 'str' Any reason why I get this warning? |
Try """ CCConfigFile.write(str(HostAddress[index]) + "\n") """
Convert the HostAddress[index] with str() before adding the line-break. |
All times are GMT -5. The time now is 04:46 AM. |