# Function print with param x def print_where_x(x): prefix = "" # for prefix space stars = "" # for stars in the middle suffix = "" # for suffix space for p in xrange(x): prefix += " " # add space in prefix suffix += " " # add space in suffix for s in xrange(25 - (x * 2)): stars += "*" result = prefix + stars + suffix print result # run logic # top down value x = 0; while(x < 13): print_where_x(x) x += 1 # bottom up value x -= 2 while(x > 0): print_where_x(x) x -= 1
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question