Is there a better way to write this block?
accident2019 = []
accident2020 = []
accident2021 = []
accident2022 = []
if year == 2019:
year_list = accident2019
elif year == 2020:
year_list = accident2020
elif year == 2021:
year_list = accident2021
elif year == 2022:
year_list = accident2022
Using string concatenation with "accident" + "year" causes Python to "forget" that accident2019 is a list, so when I try to iterate over the list, I get the characters of the word "accident2019"