Time delay indication bar for a text game
You can use bar.count rather than your sum
You can use ' ' * n, rather than your for loop.
You don't need [ in your bar.
You don't need to add whitespace, str.format can do that for you.

&gt;&gt;&gt; '[{:&lt;10}]'.format('XX')
'[XX        ]'

You don't need the bar variable.
I'd move the input out of the function, as it doesn't have much to do with the bar.
You could change the size of the bar with another argument.




def progress_bar(text, secs, size=10):
    for i in range(size + 1):
        print('{}\n\n[{:&lt;{}}]'.format(text, 'X' * i, size))
        time.sleep(secs)
        os.system('cls' if os.name == 'nt' else 'clear')




You can also remove the need for os if your terminal support \r. This will mean that you can remove text from the function too, as IMO it shouldn't really be there either.

def progress_bar(secs, size=10):
    for i in range(size + 1):
        print('\r[{:&lt;{}}]'.format('X' * i, size), end='', flush=True)
        time.sleep(secs)
    print()

print('Your text here!\n')
progress_bar(0.15)
input('&gt;')


Alternately you can use \b, this is better if you want to allow text like bar: [].

def progress_bar(secs, size=10):
    for i in range(size + 1):
        print('[{:&lt;{}}]{}'.format('X' * i, size, '\b' * (size + 2)), end='', flush=True)
        time.sleep(secs)
    print()

print('bar: ', end='', flush=True)
progress_bar(0.15)
input('&gt;')