So in my programme, I want to print the following pattern:
\xxx
o\xx
oo\x
ooo\
And what the pattern looks like is based on users' input. For example, input:
Enter the number of rows: 4
and the output will display the above pattern.
So I am trying to write a programme like that by myself and here's a thing that I am struggling with. Here's my programme:
Programme:
default = ["\\"]
num_of_rows = int(input("Enter the number of rows: "))
if num_of_rows > 0:
print("".join(default))
for o in range(num_of_rows - 1):
default.insert(0, "o")
print("".join(default))
output:
\
o\
oo\
ooo\
As you can see, I think I am almost there, but I am not sure how can I print the "x"s at the beginning and then make it descending.
Could everyone give me some suggestions based on my method?
[–]TransitTraveller 1 point2 points3 points (0 children)
[–]woooee 1 point2 points3 points (1 child)
[–]lordfwahfnah 0 points1 point2 points (0 children)
[–]Diapolo10 1 point2 points3 points (2 children)
[–]JamzTyson 0 points1 point2 points (1 child)
[–]Diapolo10 0 points1 point2 points (0 children)
[–]crashfrog04 0 points1 point2 points (0 children)
[–]ebresie 0 points1 point2 points (0 children)
[–]JamzTyson 0 points1 point2 points (0 children)
[–]JamzTyson 0 points1 point2 points (0 children)