I am wondering why I have this error when I run this code:
# Ask user input
# Find out network device id for network device with ip or hostname, index 3 is device id
# In the loop until 'id' is assigned or user select 'exit'
id = ""
device_id_idx = 3
while True:
user_input = input('=> Select a number for the device from above to show IOS config:')
user_input= user_input.replace(" ","") # ignore space
if user_input.lower() == 'exit':
sys.exit()
if user_input.isdigit():
if int(user_input) in range(1,len(device_show_list)+1):
id = device_list[int(user_input)-1][device_id_idx]
break
else:
print ("Oops! number is out of range, please try again or enter 'exit'")
else:
print ("Oops! input is not a digit, please try again or enter 'exit'")
# End of while loop
output error:
user_input= user_input.replace(" ","") # ignore space
AttributeError: 'int' object has no attribute 'replace'
This code is supposed to accept an input and return information. Thanks in advance!