Generate an Hour Glass pattern Here is my code for making an Hour Glass pattern with odd or even input using Python.  I think I could make it simpler.

Here's the output example:



And then, here is my code:

def evenGlassHour(target):
 jsp=1
 jtop=target
 jbot=2
 jbotspace=int(target/2)
 eventarget=int(target/2)
 temp=""
 for i in range(eventarget):
     for j in range(i):
         temp+=" "
     for jsp in range(jtop):
         temp+="@"
     jtop-=2
     temp+="\n"
 for i in range(eventarget-1):
     for j in range(jbotspace-2):
         temp+=" "
     for j in range(jbot+2):
         temp+="@"
     jbot+=2
     jbotspace-=1
     temp+="\n"

 print(temp)

def oddGlassHour(target):
 jsp=1
 jtop=target
 jbot=1
 jbotspace=int(target/2)
 oddtarget=int(target/2)
 temp=""
 for i in range(oddtarget):
     for j in range(i):
         temp+=" "
     for jsp in range(jtop):
         temp+="@"
     jtop-=2
     temp+="\n"
 for i in range(oddtarget+1):
     for j in range(jbotspace):
         temp+=" "
     for j in range(jbot):
         temp+="@"
     jbot+=2
     jbotspace-=1
     temp+="\n"

 print(temp)

target=int(input("Input : "))

if(target%2==0):
 evenGlassHour(target)
else:
 oddGlassHour(target)


And this is the result from my code:

 Input : 6
 @@@@@@
  @@@@
   @@
  @@@@
 @@@@@@

 Input : 7
 @@@@@@@
  @@@@@
   @@@
    @
   @@@
  @@@@@
 @@@@@@@
Read PEP8, it will give you directions on how to write Python code that look like Python code to other.

Other than that, the behaviour you're seeking is already implemented in range:

&gt;&gt;&gt; a = range(7, 0, -2)
&gt;&gt;&gt; list(a)
[7, 5, 3, 1]


You just need to reverse it to form the full hourglass:

&gt;&gt;&gt; a = range(7, 0, -2)
&gt;&gt;&gt; list(a) + list(reversed(a))
[7, 5, 3, 1, 1, 3, 5, 7]


And remove the repeated center:

&gt;&gt;&gt; decreasing = range(7, 0, -2)
&gt;&gt;&gt; increasing = reversed(decreasing)
&gt;&gt;&gt; next(increasing)  # Remove duplicated center
&gt;&gt;&gt; list(decreasing) + list(increasing)
[7, 5, 3, 1, 3, 5, 7]


Now you can make use of itertools.chain instead of list concatenation and turn your function into a generator to separate computation from printing.

import itertools


def hourglass(size):
    decreasing = range(size, 0, -2)
    increasing = reversed(decreasing)
    next(increasing, None)  # Remove duplicated center
    for length in itertools.chain(decreasing, increasing):
        yield '{:^{}}'.format('@' * length, size)


if __name__ == '__main__':
    for i in range(20):  # Test our function
        print('\n'.join(hourglass(i)), end='\n---\n')


Note that if you are using Python 3.6+ you can format the line using

yield f'{"@" * length:^{size}}'


instead which may be slightly more readable.