for x in range(0, 7) :
y = 7 - x
print(' ' * y + '*'*x)
If you squeeze the cord like this,
Here's the result.
What I want to do is
This is it. I'm going to use * to make a salty code.
for i in range(0, 7) :
for j in range(0, i):
x = 7-i
print(' '* x +str(j), end='')
print()
I made the chords like this. But now that I do this, the execution result is
It comes out like this. What should I do?
python
length = 7
for i in range(length):
print(f"{''.join(map(str, range(i)))}".rjust(length))
0
01
012
0123
01234
012345
What the questioner intended was probably the following code.
for i in range(0, 7) :
x = 7-i
print(' '*x, end='')
for j in range(0, i):
print(str(j), end='')
print()
It may be difficult because I'm a beginner, but I think I could have done it if I put a little effort into it. Think for yourself.
Try it with scalar If you're comfortable with Python, try scalar.
val l = 7
(0 to l - 1).foreach { i: Int =>
println(s"%${l}s".format(s"${(0 to i).collect {case i => i.toString}.mkString("")}"))
}
0
01
012
0123
01234
012345
0123456
© 2024 OneMinuteCode. All rights reserved.