+ 5

Help Python Print Hollow Square with Numbers

Hello! Can someone help my program to make it the same with the output below? I really need help, i'm trying to do this for loop iteration, i am quite distressed already haha 😆, you can freely edit my code so that i can also learn it through your way! Thankyouuu to those who are willing to fix my code! 💞 Example 1: Enter number of Rows: 5 Enter number of Columns: 5 Output: 12345 2      4 3      3 4      2 54321 https://code.sololearn.com/cw3cP86KFmI3/?ref=app

16th Dec 2021, 3:53 AM
Lia Costa ✨
Lia Costa ✨ - avatar
11 odpowiedzi
+ 5
Hi! You can take a look at this one for inspiration or ideas: https://code.sololearn.com/c2Pg77FsGmhG/?ref=app
16th Dec 2021, 9:36 AM
Per Bratthammar
Per Bratthammar - avatar
+ 4
sadly i am not familliar in C++ so im not quite sure i can take the logic and convert it to python syntaxes :( Ipang , but thanks for the insight!
16th Dec 2021, 4:57 AM
Lia Costa ✨
Lia Costa ✨ - avatar
+ 3
thank you so much for the idea Per Bratthammar ! ❤️
16th Dec 2021, 2:47 PM
Lia Costa ✨
Lia Costa ✨ - avatar
+ 1
👍👍👍
17th Dec 2021, 2:18 PM
satyam awasthi
satyam awasthi - avatar
+ 1
Looks fun. My entry. No need for newline separated row and column input. Just put a blank space between them, or a comma, read the included comments. Easier for cellphone users. Added the single value square suggested by ボリス . Per Bratthammar , wow, your code is built like a tank. Very thoroughly fortified.👍 Converted the code to a function so it can be called multiple times. https://code.sololearn.com/cm907j07zniZ/?ref=app https://code.sololearn.com/csm7vASnczoR/?ref=app
17th Dec 2021, 2:43 PM
Bob_Li
Bob_Li - avatar
+ 1
You can also: - create a list(s) of accending numbers based on input(s). - use lists in defining what to show on what row and in column (e.g. using indexes). For square you need only one input, the side length, so this could reduce amount of code.
17th Dec 2021, 7:53 PM
ボリス
+ 1
great feature idea. If one input, the second automatically equals that. It reduced the amount of input effort, but it added a few more lines to my code. But it's a worthwhile addition.
17th Dec 2021, 9:03 PM
Bob_Li
Bob_Li - avatar
+ 1
If only a square is required (no need for rectangle), then one option could be: https://code.sololearn.com/cEM5C8TEa2Vj/?ref=app
17th Dec 2021, 10:07 PM
ボリス
0
Have you learned C++? I did something like that long ago. Maybe you can take the logic and implement it in Python https://code.sololearn.com/cUCXrbNUe4U3/?ref=app
16th Dec 2021, 4:40 AM
Ipang
0
Lia Costa ✨ does such square called as Hollow Square ?
17th Dec 2021, 11:01 AM
Muhammad Abdulmalik
Muhammad Abdulmalik - avatar
0
You're almost there. All that you need now are separated logics for each rectangle side, so you sequence numbers accordingly. Like: if i == 0: print(<some formula>) elif j == 0: print(<another formula>) And so on.
17th Dec 2021, 3:23 PM
Emerson Prado
Emerson Prado - avatar