def convert_number_into_months_range(number):
zodiac_months = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2]
first_month = zodiac_months[number]
if number == len(zodiac_months) - 1:
second_month = zodiac_months[0]
else:
second_month = zodiac_months[number + 1]
return first_month, second_month
This is my example. It works, but looks unpythonic. On Input we have an index of the list. On return we have tuple of (index, index+1) elements of the list. If the index is pointing on the last element then we should get (last, first) elements. Is there are way to do it in more pythonicaly?