“Traceback (most recent call last):
File ”C:/py3/listkeeper.py“, line 63, in <module>
main()
File ”C:/py3/listkeeper.py“, line 4, in main
fh = choise_file()
File ”C:/py3/listkeeper.py“, line 29, in choise_file
print(”{1}: {2} file".format(lino, list))
IndexError: tuple index out of range"
Код представлен не в полном объеме, т.к. там только шаблон набросан
def main():
fh = choise_file()
if len(fh) == 0:
print("No items are in the list")
else:
for lino, line in enumerate(fh, start=1):
print("{1}. {2}".format(lino, line))
choise_func()
return
def choise_file():
fh = None
lists_all = []
lists_lst = []
lists_all = os.listdir(".")
for list in lists_all:
if list.endswith((".lst")):
lists_lst.append(list)
if len(lists_lst) == 0:
list = input("Enter name file:")
list += ".lst"
lists_lst.append(list)
fh = open(list, "w", encoding="utf8")
else:
for lino, list in enumerate(lists_lst, start=1):
print("{1}: {2} file".format(lino, list))
num_file = input("Enter number file: ")
fh = open(lists_lst[num_file-1], "w", encoding="utf8")
return fh
main()