Python possible ways | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Python possible ways

Hello guys.. I wanted to print all the possible position... For exaple max of y position is 15..and max of x.. Is 5...i want somthing like this to be printed [1,15] [2,14] [3,8] [5,9] Just all thw possible ways like this.. (those up were just exaples... I want it in order) I tried to use itertools.product...but i didint know how... I tried like this... But this will just swap the place in the possible ways itertools.product((range(1,6),range (1,16))repeat = 2)

28th Jul 2019, 1:52 PM
Amirabbas
Amirabbas - avatar
3 Answers
+ 6
print([(i,j) for i in range(1,6) for j in range(1,16)])
28th Jul 2019, 2:06 PM
Diego
Diego - avatar
+ 2
Thanks alot.. How couldn't i think of that.. 🤔🤔.. Thats a good way... Thanks again👍🏻👍🏻
28th Jul 2019, 3:02 PM
Amirabbas
Amirabbas - avatar
0
no,python easy
29th Jul 2019, 7:47 AM
Михаил Алупов
Михаил Алупов - avatar