So in my programme, I want to print the following pattern:
xxx
oxx
oox
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?
submitted by /u/Square-Reporter-1805
[link] [comments]
r/learnpython So in my programme, I want to print the following pattern: xxx oxx oox 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? submitted by /u/Square-Reporter-1805 [link] [comments]
So in my programme, I want to print the following pattern:
xxx
oxx
oox
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?
submitted by /u/Square-Reporter-1805
[link] [comments]