Aug-27-2020, 04:21 PM
For the following code:
def create_ID(tmp): try_again = True in_list = False while try_again == True: New_ID = input("Please enter the new ID") y = 0 for x in tmp: if New_ID in tmp[x][0]: # checks if ID is already in list row by row print("That ID is already on the list") # if it is return this error message in_list = True y = y + 1 if in_list == False: # if ID is not in the list close the loop try_again = False return New_IDI'm getting this error:Error:Traceback (most recent call last): File "c:/Users/djwil/Documents/python/learning python/Chapter 19 - Chunky Challenges/Passwords.py", line 173, in <module> main() File "c:/Users/djwil/Documents/python/learning python/Chapter 19 - Chunky Challenges/Passwords.py", line 150, in main New_ID = create_ID(tmp) # gets New_ID from create_ID File "c:/Users/djwil/Documents/python/learning python/Chapter 19 - Chunky Challenges/Passwords.py", line 18, in create_ID if New_ID in tmp[x][0]: # checks if ID is already in list row by row TypeError: list indices must be integers or slices, not listBut I think that I'm defining it as an integer of the a specific place in the list, can someone offer advice? 