python - Don't understand why am getting a "Tuple index out of range" error -


i new python , experiencing error many have had before yet cannot fix following code recommends games based on genre of customers' purchase history.

game_name = ["cod1", "cod2", "cod3", "skyrim", "h1z1", "csgo", "bf1", "bf3", "bf4", "gtav", "gtaiv", "fifa17", "nba2k17", "madden17", "pes2017", "nhl17", "mlb17", "pga17", "f12017", "nba2017"] history = [["cod1", "cod2", "skyrim", "h1z1", "nhl17", "mlb17", "csgo", "bf1", "bf3", "f12017"], ["fifa17", "nba2k17", "madden17", "pes2017", "cod3", "skyrim", "mlb17", "pga17", "nba2017", "gtaiv"], ["cod2", "cod3", "pes2017", "nhl17", "bf4", "gtav", "gtaiv", "mlb17", "pga17", "f12017"]] forename = ["joe", "george", "oliver"] historygenre=[["action", "action", "action", "action", "sport", "sport", "action", "action", "action", "sport"], ["sport", "sport", "sport", "sport", "action", "action", "sport", "sport", "sport", "action"], ["action", "action", "sport", "sport", "action", "action", "action", "sport", "sport", "sport"]] rr=1 actioncounter=0 sportcounter=0 while rr==1:     rec=input("who recommend games for?")     if rec in forename:         rr+=1         r=forename.index(rec)         actioncounter = historygenre[r][:10].count("action")         sportcounter = historygenre[r][:10].count("sport")         if sportcounter==actioncounter:             both_list=game_name             both_remover=0             in both_list:                 if both_list[both_remover] in history[r]:                     both_list.remove(both_list[both_remover])                 else:                     both_remover+=1                     loops=1             x in range(1):                 rec1=random.randint(0,len(both_list)-1)                 while loops==1:                     x in range(1):                         rec2=random.randint(0,len(both_list)-1)                         if rec2!=rec1:                             loops+=1                         else:                             loops=1                     loops1=1                     while loops1==1:                         x in range(1):                             rec3=random.randint(0,len(both_list)-1)                             if rec3!=rec2 , rec3!=rec1:                                 loops1+=1                             else:                                 loops1=1                       print("\n")                      print("{} likes both genres! recommend {} , {} , {} , {}".format(rec, both_list[rec1], both_list[rec2], both_list[rec3])) 

the error message occurs on last line of code , reads tuple index out of range, though both_list not tuple? others seem have had issues due fact i'm formatting index within array nothing have tried seems work , same error message appears, , don't know source of error.

looks have less arguments in format() call have {}'s.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -