The python code isnt working because the loop i think isnt doing the things in the right order. Been trying to fix this for 4hours and want to know why it is not working. Help would be appreciated
Attached Files
list index out of range
|
The python code isnt working because the loop i think isnt doing the things in the right order. Been trying to fix this for 4hours and want to know why it is not working. Help would be appreciated
Attached Files
Aug-31-2021, 05:18 PM
(This post was last modified: Aug-31-2021, 05:29 PM by deanhystad.)
You should include your code in your post, not as a link. You should also post the error message including the entire traceback. You should also provide some example input and any output
You've been looking at this for 4 hours. What have you tried to better understand the reason for the error? If you want to loop over the strings in Q1, why not do this? for word in Q1.rsplit(): if word in issues: print("We have identified the problem") break else # Didn't find word in issues humandata = input("We could not find an automated solution for you, please type as much infomation about the issue and we will let a technician sort it out") cases += 1 new_issues.write(str(cases)) new_issues.write(humandata)
Aug-31-2021, 05:26 PM
Got it working nvm
There are several ways to resolve indexerror in Python. It is not recommended to access the list or an array in any programming by using a hardcoded index value. It often leads to an exception, instead use one of the below best practices.
Checkout an article list index out of range for more details numbers = [1, 2, 3, 4, 6, 8, 10] index = 3 if index < len(numbers): print(numbers[index]) |
|