Guys ...i was training on loops and i was thinking of writing a program drawing this shape👇...but i kept thinking for 50 min ?! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Guys ...i was training on loops and i was thinking of writing a program drawing this shape👇...but i kept thinking for 50 min ?!

i think that 50 minute is much time to write this program....and is that mean that i am bad in loops or what..? the shape.... 123456 12345 1234 123 12 1 12 123 1234 12345 123456

1st Jul 2018, 9:30 AM
Omar
Omar - avatar
18 Answers
+ 4
I think you should use two nested for loops for the first 6 rows and two nested for loops for the last 5 rows.
1st Jul 2018, 9:36 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 3
When you are in the beginning of learning new things it's normal. Just don't give up and keep learning and practice writing codes.
1st Jul 2018, 10:01 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
1st Jul 2018, 10:34 AM
Louis
Louis - avatar
+ 2
There are multiple way to resolve a problem... This is true in life as in programming... Remember always this. Anyway i want post my code also 😝 https://code.sololearn.com/cNsbG2VwMGls/?ref=app About your time for get it, dont worry its very normal 😉
1st Jul 2018, 11:00 AM
KrOW
KrOW - avatar
+ 2
Louis I think that use of lambda and complex one-line expression make Omar o more confused
1st Jul 2018, 5:56 PM
KrOW
KrOW - avatar
+ 2
Louis Yes i have confused some code 😜... Anyway i refer to one-line expressions that make more confusion
1st Jul 2018, 7:20 PM
KrOW
KrOW - avatar
+ 2
so what os better my code or Louis 's code? i think his code is better than me
1st Jul 2018, 7:55 PM
Omar
Omar - avatar
+ 2
Omar o you are not asking the right questions. Why is it better.( I am not saying mine is perfect, I am also still learning) In my code, change the value of the variable in the top line, the program responds in a consistent manner. That means that the program is reusable.
1st Jul 2018, 8:26 PM
Louis
Louis - avatar
+ 2
Dont exists a perfect code... Exist a more appropriate code for some context (execution speed, memory usage, readability, reusability etc)
1st Jul 2018, 8:55 PM
KrOW
KrOW - avatar
+ 2
Omar o Don't think how long it took you, think "fantastic I did it". Perseverance is a great trait to have.
4th Jul 2018, 7:55 PM
Duncan
Duncan - avatar
+ 1
one loop and some string parsing ;) https://code.sololearn.com/cB6oyOnnaApC/?ref=app
1st Jul 2018, 1:51 PM
Markus Kaleton
Markus Kaleton - avatar
+ 1
Omar o firstly - if you declare a variable in a loop then use that variable as in for i in range(10): you now have the variable i in each iteration of the loop and it goes from 0 to 9. secondly - have a look at string formatting and do not try to position everything yourself. https://www.digitalocean.com/community/tutorials/how-to-use-string-formatters-in-JUMP_LINK__&&__python__&&__JUMP_LINK-3
1st Jul 2018, 5:42 PM
Louis
Louis - avatar
+ 1
Louis thank u☺
1st Jul 2018, 5:59 PM
Omar
Omar - avatar
+ 1
thanks bro☺ Duncan
4th Jul 2018, 8:22 PM
Omar
Omar - avatar
0
no ....i mean that i kept thinking 50 min and in the last i reached the answer ...it is 2 loops but not nested....but now i mean 50 min is a big time to reach the answer...so is that mean that i am bad or it is normal to kept tginging for 50 min?? Jay Matthews D⚽⚽⚽⚽7⃣7⃣7⃣
1st Jul 2018, 9:42 AM
Omar
Omar - avatar
0
i didnot understand your code😅
1st Jul 2018, 5:16 PM
Omar
Omar - avatar