Skip to content

Commit f83b4ba

Browse files
committed
Level 2: Lösung diamond.py
1 parent 0df445a commit f83b4ba

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Level_02/diamond.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
max_width = int(input("Maximale Breite: "))
2+
min_width = 0
3+
zeichen = input("Zeichen: ")
4+
assert len(zeichen) == 1
5+
6+
cur_width = 1
7+
while cur_width * 2 <= max_width:
8+
print(" " * (max_width - cur_width) + zeichen*(cur_width * 2 - 1))
9+
cur_width += 1
10+
11+
while cur_width * 2 >= min_width:
12+
print(" " * (max_width - cur_width) + zeichen*(cur_width * 2 - 1))
13+
cur_width -= 1

0 commit comments

Comments
 (0)