![]() |
|
[Python] Phython Question - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Phython Question (/showthread.php?tid=5134660) |
Phython Question - Webx - Jan 15, 2016 On pinychat does anyone know how to fix this error i think i fucked up something lol , line 16, in <module> if OPTIONS['ASCII']: TypeError: tuple indices must be integers, not str Heres how its written in the code # Loads the 'ascii.txt' file with ASCII text into a dictionary # ASCII in the text file must be in the format [name of ascii] [ASCII object] , the name must be one word followed by a space and then the ASCII object if OPTIONS['ASCII']: if os.path.exists(OPTIONS['path'] + OPTIONS['ASCII_file']): ASCII_dict = tinychat.fh.ascii_loader(OPTIONS['path'], OPTIONS['ASCII_file']) else: print "BOT: *The file:", OPTIONS['ASCII_file'], "was not found in the path:", OPTIONS['path'], "*" print "BOT: *As a result, ASCII was not loaded. Please check your settings.*\n\n" any idea whats wrong? * - SIM-1866423 - Jan 15, 2016 "TypeError: tuple indices must be integers, not str .." * - Webx - Jan 15, 2016 yeahhhh what does that mean how do i fix it? * - Blackājack - Jan 16, 2016 It literally means exactly what it says. When indexing a tuple, you need to use an int as the index, not a string. Find the tuple you are indexing, make sure it's supposed to be a tuple, and make sure you're indexing it right. * - lockhead - Jan 16, 2016 Like Blackjack and b3mb4m said: you need to access a tuple with an integer as an index. tup[3] gives you the 4th element of tup (start counting at zero) tup["3"] gives you an error. tup["three"] gives you an error. shouldn't be too hard to figure out. |