Sep-26-2019, 02:06 PM
(This post was last modified: Sep-26-2019, 02:07 PM by thecoziest.)
Error:TypeError: string indices must be integers
What does this error mean?I thought I would've fixed... by adding this
int(numbers[color])in
while count <= 11: for color, value in band_values.items(): if band_values[color] == int(numbers[color]): return numbersbut didn't work & brought up the same error
I'm new to using a dictionary. I'm trying to use one to help me convert the band values to numeric values by searching through a list.
#The first parameter is the two character string return earlier (numbers) #This function will convert the two characters to a number value & #return it. def calculate_raw_value(numbers): count = 0 band_values = {'K':'0', 'N':'1', 'R':'2', 'O':3'', 'Y':4,'G':5, 'L':6,'V':7, 'Z':8, 'W':9, } while count <= 11: for color, value in band_values.items(): if band_values[color] == numbers[color]: return numbers elif count <= 9: count = count + 1 continue elif count == 10: print("ERROR")
Any extra advice/tips would be appreciated.