My issue
Create a list of the first 7 months in a year
months = [“January”, “February”, “March”, “April”, “May”, “June”, “July”]
Print the first 6 months of the year
print(“First 6 months of the year:”)
for month in months[:6]:
print(month)
Print the 2nd to 5th month of the year (both 2nd and 5th included)
print(“\n2nd to 5th month of the year:”)
for month in months[1:5]:
print(month)
My code
# Create a list of the first 7 months in a year
months = ["January", "February", "March", "April", "May", "June", "July"]
print(month[:7])
print(month[1:5])
Learning course: ATT - Python
Problem Link: Slicing a list in ATT - Python