How to execute this example in console, or in One string, like lambda? Where I need to place x=x+1 to limite a loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to execute this example in console, or in One string, like lambda? Where I need to place x=x+1 to limite a loop?

x=1 m=[[1,2,3],[4,5,6],[7,8,9]] while x<10: print(list([r[2] for r in m])) x=x+1 #When I do it in console nothing is going. I guess it is necessary to relocate 'x=x+1'. I know that is easy, but I wonder because I've tried many ways...

8th May 2020, 7:33 AM
Andrey Shintar
Andrey Shintar - avatar
6 Answers
+ 1
print(*[list([r[2] for r in m]) for i in range(10)], sep="\n") https://code.sololearn.com/c287Pigt549T/?ref=app
8th May 2020, 7:58 AM
Gordon
Gordon - avatar
8th May 2020, 7:41 AM
Gordon
Gordon - avatar
+ 1
You are welcome. Here are so more ways to use print() : https://code.sololearn.com/cTiay1gR16w3/?ref=app
8th May 2020, 8:11 AM
Gordon
Gordon - avatar
0
Gordon, then there is another question: how to write this function in one string, like lambda functions? For '>>>' executing in Pycharm, for example.
8th May 2020, 7:48 AM
Andrey Shintar
Andrey Shintar - avatar
0
Gordon, it works. Thanks a lot! I went to learn a theory of Python :]
8th May 2020, 8:05 AM
Andrey Shintar
Andrey Shintar - avatar
0
Dibrey, The C language is used usually for programming of hardware and embedded devices. You can read about "uses" on the Wikipedia.
9th May 2020, 6:34 PM
Andrey Shintar
Andrey Shintar - avatar