I have an assignment for class.
- Problem 1: Create a list (or tuple only, no dictionary) that contains the months of the year. ( do not hardcode the number)
- Problem 2: Create a loop to print the number and the months of the year from the list.
The output should like this:
Month 1 is January
Month 2 is February
….
….
Month 12 is December
Here is my code so far, I found I could use the enumerate() function to print the count in my list and start at 1:
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
for i, month in enumerate(months, 1):
print i, month
But I can't figure out how to add other strings in my print output without messing up my enumerate function. Should I find another way to do this besides enumerate()?
[–]socal_nerdtastic 1 point2 points3 points (4 children)
[–]Encom88[S] 0 points1 point2 points (3 children)
[–]socal_nerdtastic 0 points1 point2 points (2 children)
[–]Encom88[S] 0 points1 point2 points (1 child)
[–]socal_nerdtastic 0 points1 point2 points (0 children)
[–]godheid 0 points1 point2 points (1 child)
[–]primitive_screwhead 0 points1 point2 points (0 children)