This is a personal memo of hacker rank.
Make a # staircase with a given integer step.
n=In case of 6
#
##
###
####
#####
######
▼my answer
python
def staircase(n):
for i in range(n):
i += 1
a = " "*(n-i)+"#"*i
print(a)
if __name__ == '__main__':
n = int(input())
staircase(n)
python
"#"*6
#output
'######'
python
"abc"*6
#output
'abcabcabcabcabcabc'
range (n)
: Numbers from 0.
→ Add 1 to n.
python
n=3
for i in range(n):
i += 1
print(i)
#output
1
2
3
Recommended Posts