Reputation: 41
I want to print the letter "H" 10 times (preferably in a loop) but for every new line that gets printed, the "H" has to move one space. How can I do this?
Here is my original code:
for a in range(0,10):
b=" "
b+=" "
print(b+"H");
Upvotes: 1
Views: 2045
Reputation: 15320
You can accomplish this simply by multiplying the index by the number of spaces you want:
>>> for i in range(10):
print i * " " + "H"
H
H
H
H
H
H
H
H
H
H
Upvotes: 3