Created
April 28, 2020 20:14
-
-
Save roman-on/01617ede24d18e6558f5d660d32d1598 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
The function accepts two parameters: the first is a single character, the second is a maximum size. | |
The function returns a string representing an "arrow" structure (see example), which is built from the input character, | |
with the center of the arrow (the longest line) being the length of the size passed as a parameter. | |
Example of the arrow function run: | |
In this example, you pass the asterisk character * and the maximum size 5. That is, the middle row is 5 in length. | |
print(arrow('*', 5)) | |
* | |
* * | |
* * * | |
* * * * | |
* * * * * | |
* * * * | |
* * * | |
* * | |
* | |
""" | |
def arrow(my_char, max_length): | |
result = "" | |
i = 0 | |
while i <= max_length-1: | |
i += 1 | |
new = my_char * i | |
result += new | |
result += "\n" | |
while i >= 0: | |
i -= 1 | |
new = my_char * i | |
result += new | |
result += "\n" | |
add_space = result.replace("", " ") | |
return add_space | |
def main(): | |
<your code here> | |
if __name__ == "__main__": | |
main() | |
print(arrow('*', 5)) | |
add_space = arrow('*', 5) | |
print (add_space) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment