odd mountain is a list of odd numbers going up from 1 and then back to 1.
e.g. odd_mountain of size 5 is [1,3,5,3,1]
odd_mountain of size 4 is [1,3,3,1]
Hint: use the list functions and a builtin function.

Can anyone help me in this? all my tries are going waste. I thought of doing it using range but getting trouble with even sizes! Please help!

The easiest to understand is to use two loops, the first going up to the halfway point and the second going down. You have to first decide how to find the halfway point for an even or odd number for the size of the mountain (note the use of two different values below). You can also use one loop, incrementing a counter by adding to it going up and subtracting from it going down but you then have to allow for two numbers in the middle that could be equal.

My preference would be to use list slicing. The following is not meant to be ready to hand in code but a rough example.

too_many_nums = [1, 3, 5, 7, 9, 11]
for length in (3, 4, 5, 6, 10):
middle, remain = divmod(length, 2)
if remain:
middle += 1
list_of_odds = too_many_nums[:middle]
## length-middle because if an odd length, the back half
## has one less value than the front, i.e. they are not equal
junk_list = too_many_nums[:length-middle]
junk_list.reverse()
list_of_odds.extend(junk_list)
print length, list_of_odds

The easiest to understand is to use two loops, the first going up to the halfway point and the second going down. You have to first decide how to find the halfway point for an even or odd number for the size of the mountain (note the use of two different values below). You can also use one loop, incrementing a counter by adding to it going up and subtracting from it going down but you then have to allow for two numbers in the middle that could be equal.

My preference would be to use list slicing. The following is not meant to be ready to hand in code but a rough example.

too_many_nums = [1, 3, 5, 7, 9, 11]
for length in (3, 4, 5, 6, 10):
middle, remain = divmod(length, 2)
if remain:
middle += 1
list_of_odds = too_many_nums[:middle]
## length-middle because if an odd length, the back half
## has one less value than the front, i.e. they are not equal
junk_list = too_many_nums[:length-middle]
junk_list.reverse()
list_of_odds.extend(junk_list)
print length, list_of_odds

Thanks for the reply but I'm not allowed to use loops and the question says it can be done easily by using an inbuilt function :/

Hi,
I have a DGV (dgvListOfJobs), populated from an SQL database to show the user a list of 'jobs' (i.e. rows). I also show 7 other DGV's (dgvMonday, dgvTuesday, etc) ...

Write a looping program for Theater Seating selection
The program will display the theater seating (shown later) and prompt the user to select a seat to purchase using the row ...