Home > Software design >  I don't know why I get an error in this code. Error: List index out of the range [closed]
I don't know why I get an error in this code. Error: List index out of the range [closed]

Time:09-17

App is kivy app, which is suppose to take 8 arguments in entry and put them in print_file. Instead of entry in this code I used an data_list in which I would save entry arguments.

data_list = ["Nik," "Tim," "Nace," "Peter," "Tadej," "Julij," "Marjan," "Slavko"]


print_file = open("print.txt","a ")
print_file.write("First game, first court: "   data_list[0]   " and"   data_list[1]   " against "   data_list[2]   " and"   data_list[3]   ".")
print_file.write("First game, second court: "   data_list[4]   " and"   data_list[5]   " against "   data_list[6]   " and"   data_list[7]   ".")

I also tried with writing list without " but it still didn't work

CodePudding user response:

your datalist is wrong list fomat, fix it like this

data_list = ["Nik", "Tim", "Nace", "Peter,", "Tadej", "Julij", "Marjan", "Slavko"]
  • Related