Jan-13-2024, 07:06 PM
(This post was last modified: Jan-13-2024, 07:07 PM by deanhystad.)
There is no error in the posted code. The error message indicates that sometimes you indent using tabs and other times using spaces. I think this gets cleaned up by the python tags.
This code runs fine for me:
This code runs fine for me:
choices = list("ABCD") menu = "" opts1 = [] for idx, choice in enumerate(choices): menu += str(idx).ljust(6) + choice + "\n" opts1.append(str(idx))But this code that looks identical generates the error you are seeing.
choices = list("ABCD") menu = "" opts1 = [] for idx, choice in enumerate(choices): menu += str(idx).ljust(6) + choice + "\n" opts1.append(str(idx)) # Starts with a tab instead of 4 spaces.
Error: opts1.append(str(idx))
TabError: inconsistent use of tabs and spaces in indentation
Next time you post be sure to include the entire error message.