Why it is showing nothing when I print L in it | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why it is showing nothing when I print L in it

What L is empty But if i put L in inside loop it is executing https://code.sololearn.com/c3mjRgul7WsJ/?ref=app

15th Sep 2020, 3:41 AM
Shivam Kumar
Shivam Kumar - avatar
7 Answers
0
import random l=[] while len(l)<4: x=random.randrange(5) y=random.randrange(5) if x+y==5: if [x,y] not in l: l.append([x,y]) print(l)
15th Sep 2020, 7:27 PM
Ruba Kh
Ruba Kh - avatar
+ 1
It is not empty, there is no output because your code is inside an infinite loop so it will not reach the line with print(l) because it will stay in the loop
15th Sep 2020, 3:45 AM
Ruba Kh
Ruba Kh - avatar
+ 1
I need last line of : [[1,4],[3,2],[ 2,3],[4,1]] order is not important
15th Sep 2020, 8:03 AM
Shivam Kumar
Shivam Kumar - avatar
+ 1
Thanks
16th Sep 2020, 4:24 AM
Shivam Kumar
Shivam Kumar - avatar
0
What should i do
15th Sep 2020, 3:58 AM
Shivam Kumar
Shivam Kumar - avatar
0
To get desired output
15th Sep 2020, 3:58 AM
Shivam Kumar
Shivam Kumar - avatar
0
What is the desired output that you need?
15th Sep 2020, 4:02 AM
Ruba Kh
Ruba Kh - avatar