11 Answers
+ 2
Regarding some smart tutorial, someone already suggested this: https://goalkicker.com/PythonBook/ In my opinion is one of the best Python book ever written, and it is completely free!
3rd Sep 2019, 8:14 PM
Bilbo Baggins
Bilbo Baggins - avatar
+ 5
I did not pay attention, corrected https://code.sololearn.com/c6YID48HG3Ov/?ref=app
2nd Sep 2019, 5:37 PM
Mikhail Gorchanyuk
Mikhail Gorchanyuk - avatar
+ 3
https://code.sololearn.com/cEEYYUAm6GHn/?ref=app
2nd Sep 2019, 7:38 PM
portpass
+ 2
You see, you repeat at each iteration the same pattern. Increase n, then print each line from n to 5. for j in range(...) can be replaced by: for j in range(5 - n), you see ? You only need tow nested loops, one incrementing n, and the second with j. I will give you my code if you find the way.
2nd Sep 2019, 5:22 PM
Théophile
Théophile - avatar
2nd Sep 2019, 7:34 PM
Bilbo Baggins
Bilbo Baggins - avatar
+ 2
Sure! Central idea of both implementations is the star operator ("iterable unpacker"), which transform a list of elements in a sequence of elements. So: print(*[1,2,3]) becomes print(1,2,3) The list is created using the range() function. In my implementation, I used the "list comprehension" syntax, used for generating a list l1 starting from another list l: l1 = [ f(x) for x in l] In my initial line, I tried only one print on a list of lists, starting a new line at every new element. Something like: print(*[ *[1,2,3,4], *[2,3,4], *[3,4], *[4]], sep='\n') This means two nidified list comprehensions. Unfortunately we cannot use the star inside a list comprehension, so I separated the elements passing from int to str (map) and rejoining them with spaces. Better and more readable solution: only one list of many prints: [print(*range(n,5)) for n in range(1,5)]
3rd Sep 2019, 6:19 AM
Bilbo Baggins
Bilbo Baggins - avatar
+ 1
ĐœĐžŃ…Đ°ĐžĐ» Đ“ĐŸŃ€Ń‡Đ°ĐœŃŽĐș your program is printing a wrong pattern
2nd Sep 2019, 6:36 PM
Elanon
Elanon - avatar
+ 1
Bilbo Baggins and portpass can you please explain your approach????
3rd Sep 2019, 3:11 AM
Elanon
Elanon - avatar
+ 1
And thanks all of you Bilbo Baggins ,portpass Théophile ,Sousou, Mike for your support . This is a great community indeed.
3rd Sep 2019, 7:27 PM
Elanon
Elanon - avatar
0
Bilbo Baggins can you suggest some good tutorials where I can learn this stuff???
3rd Sep 2019, 7:22 PM
Elanon
Elanon - avatar