Consider I have three lists, stored in file sports.py
, which is separate from the .py file I'm working in:
games_1 = ["Tennis", …]
games_2 = ["Cricket", …]
games_3 = ["Golf", …]
I also have a variable var_game == "Football"
.
I would like to check which lists var_game
appears in. So far I have tried:
for N in range(1,3):
if var_game in sports.games_N:
gamesN_check = 1
else:
gamesN_check = 0
However, Python does not let me use N to cycle through the lists in this way. How do I need to use it with the correct syntax?
Many thanks in advance!
Aucun commentaire:
Enregistrer un commentaire